View Full Version : passing a value from one form to another form


hyousef
01-24-2002, 11:40 AM
I have a form that contains several text boxes, one of the text boxes is a "project Number", for example, the project number for the first record is "P14X" and the project number for the second record is "P14XZ" and so on..
Lets say i am viewing "record 1" and the project number is "P14X"...what i want is when i click "open" button to open another form pass this project number "P14X" that i am currently viewing to a second form, so it will be automatically entered in a field in the second form.
How can i do that?
Thanks in advance.

jwindon
01-24-2002, 11:49 AM
Pass the value of your pk on your first form to the second using the OpenArgs of the open form action.

DoCmd.OpenForm "frmForm2",,,Me.Proj#FieldName

On the OnOpen event of the other form:

If Not IsNull (Me.OpenArgs) Then
Me.Proj#FieldNameField = Me.OpenArgs
Exit Sub
End If

hyousef
01-24-2002, 01:59 PM
Thanks Jwindon it works, http://www.access-programmers.co.uk/ubb/redface.gif)