Setting arguments within form

S

Steve P.

I have a single report that has 2 text boxes, which by
default are set to not visible. This report can be printed
from 3 different forms. Depending on the form it is
printed from, I want a particular text box to be set to
visible. Can I set this in the code as an argument???

Thanks in advance.
 
A

Allen Browne

In Access 2002 and 2003, you could pass the name of the text box to show in
the OpenArgs of the report:
DoCmd.OpenReport "MyReport", acViewPreview, OpenArgs:="Text1"

Then in the Open event of the report, you could set the Visible property of
the text box:
Private Sub Report_Open(Cancel As Integer)
If Len(Me.OpenArgs) > 0 Then
Me(OpenArgs).Visible = True
End If
End Sub

In earlier versions, you would need to use a public string variable to pass
and reset this control name.
 
Top