Label Visibility basied on Field value

MayaMana

Registered User.
Local time
Today, 03:49
Joined
May 29, 2012
Messages
60
I have a report (in access 2007) that has labels on the bottom where certain people need to sign once the report is printed out. I am trying to figure out how to make it so that only the labels that have been checked for that record show (since not everyone will need to sign all the time). Right now the codes I have tried without success are:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Reports![ReportGC]![Manufacturing] = True Then
Reports![ReportGC]![ProductionSuperintendent].Visible = True
Else
Reports![ReportGC]![ProductionSuperintendent].Visible = False
End If

End Sub
&
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.ProductionSuperintendent.Visible = Nz(Me.Manufacturing, 0)
Me.ProcessingSuperintendent.Visible = Nz(Me.Manufacturing, 0)
Me.Engnineering.Visible = Nz(Me.Engineering, 0)
Me.SafetySupervisor.Visible = Nz(Me.Safety, 0)
End Sub

Any advice/help is greatly appreciated.
 
Last edited by a moderator:
Re: Lable Visibility basied on Field value

Is Manufacturing a Yes/No field?
 
Re: Lable Visibility basied on Field value

Yeah, they are all yes/no fields.
 
Re: Lable Visibility basied on Field value

And the four controls that you wish to hide are labels that are not attached to any other controls, like a textbox for example?
 
Re: Lable Visibility basied on Field value

No, they are just labels.
 
Re: Lable Visibility basied on Field value

Your code looks alright. Can you upload a sample db.
 
Re: Lable Visibility basied on Field value

How do I make a db sample small enough to post on here?
 
Re: Lable Visibility basied on Field value

If you copy and pasted the code, this is spelled wrong:
Me.Engnineering.Visible = Nz(Me.Engineering, 0)
 
Re: Lable Visibility basied on Field value

* Create a table from the recordsource of your report
* Remove sensitive data and leave some test data
* Create a report based on this table
* Upload this cutdown version
 
Re: Lable Visibility basied on Field value

If you copy and pasted the code, this is spelled wrong:
Me.Engnineering.Visible = Nz(Me.Engineering, 0)
Well spotted!

Debug > Compile your code as well, before uploading.
 
Re: Lable Visibility basied on Field value

Okay, give me a moment to make that.
Thank you, even with just the ones above that it wasn't working though. I will fix it though.
 
Re: Lable Visibility basied on Field value

Okay, I fixed the spelling on the report and code so that they should be correct also.
 

Attachments

Re: Lable Visibility basied on Field value

You're trying to run the code in Report View. The Format event doesn't fire in Report View.

Your code will work when you print it out or when you open it in Print Preview.
 
Re: Lable Visibility basied on Field value

Is there a way to have it work in Report View also?
 
Re: Lable Visibility basied on Field value

Nope !!!

Actually you can use Conditional Formatting to change the ForeColor to white.
 
Re: Lable Visibility basied on Field value

Okay, thank you :)
 

Users who are viewing this thread

Back
Top Bottom