Set a value on a form

  • Thread starter Thread starter Samuel
  • Start date Start date
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
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top