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
Serena2345Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jeffrey CoachmanMIS LiasonCommented:
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
Jeffrey CoachmanMIS LiasonCommented:
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
Serena2345Author Commented:
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
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

Jeffrey CoachmanMIS LiasonCommented:
New sample attached.

As I stated, you need to pen the report in Print Preview specifically for the code to work.
Database78.mdb
Jeffrey CoachmanMIS LiasonCommented:
Or if Print Preview is not a god fit for you, ...
you can convert the label to a textbox (Contrlsource: "Closing Date")
Then use conditional formating:
Expression: IsNull(ClosingDate)
...then set the text color to white

Sample 3 attached
Database78.mdb

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jeffrey CoachmanMIS LiasonCommented:
I see our posts crossed.
I posted the code correction here
;-)
Serena2345Author Commented:
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
Serena2345Author Commented:
I meant to give 500 points
Jeffrey CoachmanMIS LiasonCommented:
;-)

Glad I could help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.