Passing field value from one form to another form that creates a new record

duthiedon

Donner
Local time
Today, 01:28
Joined
Dec 27, 2007
Messages
60
I have several different sub-forms that have a button that opens a new form which creates a new record. Each of the different sub-forms have a field value that needs to be passed to the new record when the other form is opened. I've tried a few solutions, but to no avail. Right now I'm using the macro functionality as follows for one of the subforms:

ACTION ARGUMENTS
--------------------------------
RunCommand SaveRecord
OpenForm frmDocumentNew, Form, , [AssociatedClientTracking]=[Forms]![sfrm_ClientTracking]![ID-ClientTracking], , Normal
OnError Next,
GoToRecord ,,New,
MsgBox =[MacroError].[Description], Yes, None,
SetProperty [AssociatedClientTracking], Enabled, Me.ID-ClientTracking

The problem I think is that I'm creating a new record so the value doesn't get passed. The new record is only created after the user begins to enter data in the new form that was opened.

Any assistance is greatly appreciated!

Thanks,
Don
 
Let's use VBA here. You can use the OpenArgs to pass the value you want to the receiving form.

DoCmd.OpenForm "frmDocumentNew", OpenArgs:=Me![ID-ClientTracking]

and in the receiving form's On Load event
Code:
If Len(Me.OpenArgs & vbNullString) > 0 Then
   Me!AssociatedClientTracking = Me.OpenArgs
End If
 
Thanks very much! Works beautifully! The only change I had to make was in placing the code in the receiving form, had to place it on "after update" instead of "on load" due to the nature of the form.
 

Users who are viewing this thread

Back
Top Bottom