Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with code to hide label

Status
Not open for further replies.

3699wat

Technical User
Sep 30, 2002
28
US
I usually do not post the same problem at multiple sites, but I am desperate for help.
I am looking for the code that will set all labels in the section of one report to not visible when the corresponding fields are empty.

The report is bound to a query populated by a form. Each form receives specific info for a different person and shows it on the appropriate report.

I can get the desired result with the following code, but only if used once ( the code is set in the OnFormat event procedure of the Detail section)

If Me. TextboxA = " " or IsNull (Me.TextboxA) Then
Me.LabelNameA. Visible = False
End if

If Textbox A is empty on form 1 than report 1 shows no label and box and when Textbox A has data on form 2 both will shows. Ok so far

If I enter the in the same procedure for Textbox B and enter only data on form 2, it will do the trick for report1 (no data, no label), but on report 2 it only shows the data (as expected) but the label is gone.

Question 1
Why is this happening?
Question 2
Can someone help me with a single code that would do the trick for all empty textboxes at the same time

Thank you
 
3699: I'm sure we could handle this problem but you need to be a tad bit clearer.

Be a bit more technical and provide where, when, what on your code. Your problem seems simple enough, not quite clear on the dynamics here.
 
Hi,

I had a similar issue with one of my systems. To make life easy for me (I didn't know code at all) I used text boxes as labels, with the control source:

=iif(isnull([dataItem],"","Data Label")

is probably slow, but always does the job.

Cheers

Steve
 
you may have to perform this during other events associated with the report as well.
 
Steve
The code works fine and I don't mind setting it for each field. What I'm also looking for is for the next textbox to move into the space of the previous empty one. I did set the properties to Can Shrink and Can Grow, but it doesn't work.
Any suggestions
Marcel
 
Try this code in you format event:

Me.LabelName??.Visible = IIF((NZ(Me.Textbox??),"") = ""), false, true)

where ?? would be your field specific name.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top