Pass Data from SubForm to New Form

B

BMoroneso

Hi everyone,
I am working on a database that tracks insurance policies for clients. I
have a main client form (frmClient) with several subforms on a tab control.
On the policies subform (displayed as a datasheet, master/child link is
ClientID), I am only displaying a few key pieces of data, and am not allowing
adds. I have a button on the tab control to add a new policy. This brings
up a new form (frmAddClientPolicyDetail) in add mode.

DoCmd.OpenForm "frmAddClientPolicyDetail", , , , acFormAdd, acWindowNormal

I need to pass the ClientID parameter into frmAddClientPolicyDetail, but
can't figure out how to do that.

Thanks in advance for your help!
 
K

Klatuu

The easiest way d be to pass the ClientID to frmAddClientPolicyDetail using
the OpenArgs argument of the OpenForm method. then in the Load event of
frmAddClientPolicyDetail you can use Me.OpenArgs to assign the value to the
control bound to the ClientID field.
 
B

BMoroneso

Hi Dave,
I'm at a loss as to how to store that value in the OpenArgs argument. Can
you shed some more light? thanks!
 
K

Klatuu

Since your subform is linked to ClientID and the command button is on the
main form, all you need is to pass it the value of the control on you main
form that is bound to the ClientID field:

DoCmd.OpenForm "frmAddClientPolicyDetail", , , , acFormAdd, acWindowNormal,
Me.txtClientID

Now, in the Load even of frmAddClientPolicyDetail:

If Not IsNull(Me.OpenArgs) Then
Me.txtClientID = Me.OpenArgs
End If
 
B

BMoroneso

Wonderful - thanks so much!!!

Klatuu said:
Since your subform is linked to ClientID and the command button is on the
main form, all you need is to pass it the value of the control on you main
form that is bound to the ClientID field:

DoCmd.OpenForm "frmAddClientPolicyDetail", , , , acFormAdd, acWindowNormal,
Me.txtClientID

Now, in the Load even of frmAddClientPolicyDetail:

If Not IsNull(Me.OpenArgs) Then
Me.txtClientID = Me.OpenArgs
End If
 
Top