Link to home
Start Free TrialLog in
Avatar of Serena2345
Serena2345Flag for United States of America

asked on

Conditionally hide a label on an Access report

Please see sample atttached. I want to hide the label "Closing Date" when there in no date below it. I am working in Access 2007 Sample.pdf
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Your screenshot is confusing as there appears to be many "Closing Date" labels on each row...?

In any event, ...On the format Format event of the section the label is in, ...do something like this:
If IsNull([ClosingDate] Then
    me.ClosingDateLabel.Visible=False
else
    me.ClosingDateLabel.Visible=True
End If

Then open the report in Print Preview
Code correction:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    If IsNull([ClosingDate]) Then
        Me.ClosingDateLabel.Visible = False
    Else
        Me.ClosingDateLabel.Visible = True
    End If
End Sub

Sample attached
Database78.mdb
Avatar of Serena2345

ASKER

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If IsNull([ClosingDate] Then
    Me.ClosingDateLabel.Visible = False
Else
    Me.ClosingDateLabel.Visible = True
End If
End Sub
It gives me a syntax error
New sample attached.

As I stated, you need to pen the report in Print Preview specifically for the code to work.
Database78.mdb
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I see our posts crossed.
I posted the code correction here
;-)
I've requested that this question be closed as follows:

Accepted answer: 0 points for Serena2345's comment #a40788254

for the following reason:

thanks for all your help. I wish I could give more that 500 points
I meant to give 500 points
;-)

Glad I could help.