472,325 Members | 1,025 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,325 software developers and data experts.

Hide labels and textboxes

I have a report in Access 2003. If I set the can shrink property on the textboxes they are invisible when they are empty, which is what I want. But it does not hide the associated label connected to it. Is that possible to do, either with vba or visual basic 6?
Thanks
Jan 20 '07 #1
12 42702
nico5038
3,080 Expert 2GB
Use for each field this code in the Detail's On Print event:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
  2. If Len(Nz(Me.YourField)) > 0 Then
  3.    Me.Label1.Visible = True
  4. Else
  5.    Me.Label1.Visible = False
  6. End If
  7. End Sub
This will hide (and free the space) the label.

Nic;o)
Jan 21 '07 #2
NeoPa
32,511 Expert Mod 16PB
I have a report in Access 2003. If I set the can shrink property on the textboxes they are invisible when they are empty, which is what I want. But it does not hide the associated label connected to it. Is that possible to do, either with vba or visual basic 6?
Thanks
To nick some of Nico's answer shamelessly (I wouldn't have thought of the Detail_Print event, but maybe the OnCurrent event would have worked as well) :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
  2.     Me!YourField.Visible = (Me!YourField>"")
  3. End Sub
I simply set the Visible property of the TextBox as this will handle both automatically assuming they're linked. The code is shorter but perhaps a little less obvious to the casual reader. The Visible property is set to the boolean value returned by the equation.
To be clear, this is an alternative, not a fix, to Nico's code, which will work fine for you.
Jan 22 '07 #3
I have a similar issue and used the code provided to hide the labels of the fields with no data. I have another question, is there a way to shrink the white space so the fields compact together--as it is, the fields are hidden, but it is like there is space reserved for the fields (they are just do not appear, but have enough space on the report to appear)...
Feb 13 '07 #4
Rabbit
12,516 Expert Mod 8TB
To shrink the white space you'd have to use code to either A) Move all controls over, expressed in twips or B) Set the X,Y coordinates for all the controls you want to move, expressed in twips.

For A, use:
Expand|Select|Wrap|Line Numbers
  1. Me.Control.Move Left, [Top], [Width], [Height]
For B, use:
Expand|Select|Wrap|Line Numbers
  1. Me.Control.Left = #
  2. Me.Control.Top = #
Feb 13 '07 #5
To shrink the white space you'd have to use code to either A) Move all controls over, expressed in twips or B) Set the X,Y coordinates for all the controls you want to move, expressed in twips.

For A, use:
Expand|Select|Wrap|Line Numbers
  1. Me.Control.Move Left, [Top], [Width], [Height]
For B, use:
Expand|Select|Wrap|Line Numbers
  1. Me.Control.Left = #
  2. Me.Control.Top = #
Sorry, this is all new to me, I will try the Me.Control.Move Left, [Top],[Width]...etc, but is the "Me" part the name of the label or field? and the "Top", "Width" is expressed in inches?
Feb 13 '07 #6
Rabbit
12,516 Expert Mod 8TB
Me is a reference to the form. Replace Control with the name of the control you want to move. Replace Left, Right, Height, Width with numbers expressed in twips (twip: Unit of measurement that is equal to 1/20 of a point, or 1/1,440 of an inch. There are 567 twips in a centimeter.)

So, if you have a text box named Foo and you need to move it 567 twips to the left, which is one centimeter, then you would use:
Expand|Select|Wrap|Line Numbers
  1. Me.Foo.Move -567
Top-Left is coordinate (0,0)
Feb 13 '07 #7
That makes sense...one last question, which section of the VB code does this go in, (Detail Print?)
Feb 13 '07 #8
Rabbit
12,516 Expert Mod 8TB
I'd put it in whichever Sub is hiding the labels.
Feb 13 '07 #9
Thanks, I will give it a try.
Feb 13 '07 #10
I'd put it in whichever Sub is hiding the labels.
Hi, I am trying to do the same thing as TinyTim but I am having problems. The invisible part works, but moving the text gives me an error. Here is what I have, can you tell me what I'm doing wrong?

Expand|Select|Wrap|Line Numbers
  1. If Len(Nz(Me.app)) > 0 Then
  2.  Me.app1.Visible = True
  3. Else
  4.  Me.app1.Visible = False
  5.  Me.app1.Move Top - 567
  6. End If
Apr 6 '07 #11
NeoPa
32,511 Expert Mod 16PB
Try :
Expand|Select|Wrap|Line Numbers
  1. If Len(Nz(Me.app)) > 0 Then
  2.  Me.app1.Visible = True
  3. Else
  4.  Me.app1.Move Top - 567
  5.  Me.app1.Visible = False
  6. End If
If this doesn't work, then post the question in a new thread.
This thread is not for your question.
Apr 10 '07 #12
NeoPa
32,511 Expert Mod 16PB
Another post was added to this thread but wasn't relevant so I've moved it to its own thread at How Do I Check Date Control is Filled.
Jan 18 '15 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Dalan | last post by:
I have been using a module for printing labels in Access 97, and although it works fine, I would like to add a small enhancement to it. The module...
1
by: Rohan | last post by:
Hi There, Is it possible to rotate or resize pictureboxes, labels, textboxes at runtime? And I even wanted to make textbox and label...
1
by: jyothi1105 | last post by:
Hi, I want to add textboxes and labels at runtime. Controls are to be added according to the value entered in textbox. txtfamily is a textbox,in...
3
by: DAnDA | last post by:
Hi Simply i want Hide all Textboxes in a Panel ,,, in asp.net i can do it by C# : foreach (Control ctrl in Panel1.Controls)...
1
by: DAnDA | last post by:
Hi Simply i want Hide all Textboxes in a Panel ,,, in asp.net i can do it by C# : foreach (Control ctrl in Panel1.Controls) { if (ctrl is...
1
nev
by: nev | last post by:
After adding a datasource, I can see my tables in the right-pane of my IDE. Some tables I placed on my form as a datagrid and others as detail view...
2
by: englishman69 | last post by:
Hello, I have been banging my head against this one for a while... Searches online have revealed many different proposals for correcting my...
1
by: sahilansari | last post by:
I have two Radio buttons. radio_date & radio _reg. Initially radio_date is checked by default.(On form load)....So i want to display two textboxes...
2
by: Bay0519 | last post by:
Hi, I really need someone help.. I'm using access 2003 by the way. I have a form where users enter their time card. right now I have 15 lines...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.