473,413 Members | 2,058 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 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 43075
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,556 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,556 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,556 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 allows for setting the number of labels to print...
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 controls Transperent ?
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 which user gives the no of familymembers. i want...
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) { if (ctrl...
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 TextBox) {
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 (textbox w/ labels). Hiding a column in the...
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 issue but none that I can follow! My basic situation...
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 & related labels.All this data is in a table.As...
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 (including textboxes and combo boxes in each...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.