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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Having "text" inserted only when field has a value.

Status
Not open for further replies.

jblackburn

Technical User
Jun 25, 2002
2
US
Is there any way to have "label" inserted into a report ONLY WHEN the corresponding field actually contains something? IN OTHER WORDS, whenever a field contained in the report is left blank, I want the corresponding label for that field also left out of the report. Is this possible? (~ I realize this is probably a simple question. Please orgive my ignorance! I am new non-professional member of this forum looking for help.)
 
There are probably a few ways to do that with VBA, but I find the easiest way to use labels is not to use them. Insert a TextBox instead. To get fixed text enter ="Whatever", or if it needs to be dependent on another field enter =iif([INVENTORY]=0,"","Inventory"), so every time the INVENTORY field equal zero you text box will show an empty string ""; otherwise, I will simply say Inventory, like a label. Hopefully that helped.
 
I started this thread, and thank you "flan.."'s for your post. (I was sure it would work!) However: Neither
=IIf(IsNull([INFO TRAC])," ","Info Trac " & [INFO TRAC]) OR
=IIf([INFO TRAC]=O," ","Info Trac " & [INFO TRAC])
worked for some reason - though the latter was taken directly from the MS Access Help under "examples of manipulating a text value in a report". If anyone can provide any other options for my problem, it would be appreciated.
 
When you say it doesn't work, do you get Error printed or always Info Trac ?

If it is Error then the problem might be the name of the text box, if this is info trac than you need to change it to something else.

If if always prints Info Trac then you could try comparing it with "" instead os IsNull

HTH

Jane
 
If you are trying to suppress the associated label with a text box when the text box is empty, try code like this in the On Format event of the report's detail section:
Code:
If IsNull([INFO TRAC) Then
Me.lblINFO.Visible = False
Else
lblINFO.Visible = True
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top