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

leave off fields in a subreport depending on their value 1

Status
Not open for further replies.

gse14

Technical User
May 15, 2004
20
US
I would like to have several fields (and their labels) in a subreport NOT show up on a report if they do not contain any value. Is it possible to have fields visible on a report depending on it's value?

if field = 0 then do not show that particular field on the report.

I am creating an invoice report and certain clients get a "professional discount". If someone isn't getting a discount, I don't want "professional discount = blank" to show up. I would prefer to leave the entire field off so that the client isn't aware that other people may be receiving a professional discount.

Thanks,
Gretchen
 
Add code in the On Format event of the section containing the controls:
If Me.txtYourField = 0 Then
Me.txtYour.visible = False
Me.lblYourLabel.visible = False
Else
Me.txtYour.visible = True
Me.lblYourLabel.visible = True
End If


Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Thanks Duane, you have pretty much written any fancy code this database has.

How would I add multiple fields to the code. If I want more than one field and label to not show up if there is no value?

Thanks for the help!
Gretchen
 
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

Do I have to change this line? When I run the report this is showing up highlighted in yellow.

 
When you first open the Format Event code, you will see two lines of code. Don't mess with these. Just place your code between the lines.

You can reference more controls by copying the code I supplied and pasting it above or below my sample (stay between the lines) and changing the control names.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
It works for the fields that have a "0" (zero) in the field. How do I eliminate control labels that have Null or no value?

Thanks.
Gretchen


 
To determine if a text box contains a null, use
If IsNull(Me.txtYourTB) Then
or
If Len(Trim(Me.txtYourTB & ""))=0 Then

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top