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

Make control on report visible depending on where print cmd is called 1

Status
Not open for further replies.

shards

Technical User
Mar 26, 2008
10
US
I have a report for incidents and accidents that, depending on where the report is generated from, a drug_test control needs to be visible or not.

If the report is generated from the cmdPrintReport button on the form f_safety, then I want the drug_test control to be visible. If it is printed from anywhere else, I want it to not be visible.

Can you help?
Thanks!!
 
You could set a global variable or test to see if f_safety is loaded. This could be done in the load event of the report and the visible property could then be changed based on the result.
 
Thanks, Remou and dhookom. I've tried the following code in both the On Load and On Format events in the report and get a compile error that the sub or function is not defined when I attempt to print the report form the form. The report will still open with no error if the report is opened directly...but the drug_test control still appears on the report. (I'm a novice at best with this stuff)

Any help on what I'm doing wrong?

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Not (IsLoaded("f_safety")) Then
drug_test.Visible = False
Else
drug_test.Visible = True
End If
End Sub
 
As Duane said, there is no load event [blush]

Code:
Private Sub Report_Open(Cancel As Integer)
If CurrentProject.AllForms("f_safety").IsLoaded Then
    Me.drug_test.Visible = True
Else
    Me.drug_test.Visible = False
End If
End Sub
 
Remou - you are fabulous! That worked. Thanks a bunch.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top