Use value from a sub-form field to populate a field on another form

cavscout

Registered User.
Local time
Yesterday, 20:35
Joined
Mar 13, 2003
Messages
74
I want the user to click a button on a sub-form (continuous form format) and pass the value of a field (ColorCode) in that record to a new form which opens from the button click and autopopulate the field (ColorCode) on the new form.

First Form is: On button click

stDocName = "frm-EditPaintAllocation"
DoCmd.OpenForm stDocName, , , , , , Me.ColorCode.Value


Second Form is:

Private Sub Form_Open(Cancel As integer)
DoCmd.GoToRecord acDataForm, "frm-EditPaintAllocation", acNewRec
If Not IsNull(Me.OpenArgs) Then Me.ColorCode = Me.OpenArgs
End Sub

The code above appears to not recognize the OpenArgs that is being passed from the first form as I tried this with a Select Case method and the last Case was returned.

I'm not seeing why this isn't working. If anyone can point out the issue please?

Thanks!
 
the problem as I see is the open event not in the code
put that code newrec and if on the first button and not on open event and should work.
if not put all in a module and call it from the 1st button, it works to me
 

Users who are viewing this thread

Back
Top Bottom