Set a value on a form

S

Samuel

I use the following code to open a form
DoCmd.OpenForm stDocName, , , stLinkCriteria

Is there any way to pass data to the form (through the constructor) or to
set the value of a label on the form

Thank you,
Samuel
 
K

Ken Snell \(MVP\)

You can use the OpenArgs argument to pass a value to the new form, and then
use the new form's Load event to read the value and put it into a control on
itself.

First step -- pass the value:

DoCmd.OpenForm stDocName, , , stLinkCriteria, , "ValueToPass"



Second step - read the value and use it; this code goes with the Load event
of the stDocName form:

Private Sub Form_Load()
Me.LabelName.Caption = Nz(Me.OpenArgs, "")
End Sub
 
S

Samuel

Thank you,

Samuel

Ken Snell (MVP) said:
You can use the OpenArgs argument to pass a value to the new form, and
then use the new form's Load event to read the value and put it into a
control on itself.

First step -- pass the value:

DoCmd.OpenForm stDocName, , , stLinkCriteria, , "ValueToPass"



Second step - read the value and use it; this code goes with the Load
event of the stDocName form:

Private Sub Form_Load()
Me.LabelName.Caption = Nz(Me.OpenArgs, "")
End Sub
 
Top