pass a generated value to a TextField in a new form

P

PQR

I have two forms not connected to any table:
(1)frmFirst
(2)frmSecond
frmFirst generates a id-serial strSerialid
On clikcing the commandbuttom cmdSubmit frmFirst is closed
and frmSecond is opened
The problem:
The strSerialId generated in frmFirst has to be displayed
in the txtSerialId
How can this be realized.
 
K

Ken Snell

Assuming that txtSerialsId is a textbox in frmSecond, use the OpenArgs
argument of the DoCmd.OpenForm action to carry the value from the first form
to the second form, and then have the second form read the OpenArgs argument
and use it to set the value of the textbox.

In the first form's code that opens the second form:
DoCmd.OpenForm "frmSecond", OpenArgs:=strSerialID

In the second form's OnLoad event, use this code:
Private Sub Form_Load()
Me.txtSerialId.Value = 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

Top