Pass Data from SubForm to New Form

  • Thread starter Thread starter BMoroneso
  • Start date Start date
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!
 
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.
 
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!
 
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
 
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
 
Pass Data from Form to Sub Forms

Hello

I wonder if anyone can help me with this please, which is similar to the issue already resolved in this thread.

I would like to pass a date value from a form to 7 subforms representing the days in the week notified in a WeekCommencing date field on the parent form. ie so that when a tabbed subform is selected it will have a date field set to show the correct date for that particular day of the week in the week identied on the main form.

I can work out the syntax to make this work with absolute dates, but I can't see how to make it work with a date value which can vary when the main form is opened for different weeks. Effectively the sub forms need to take as their date value mainform.WeekCommencing +0,+1,+2,...+6 respectively. Sounds easy doesn't it? Is It?

I am using MS Access 2003 on a WinXP Pro machine. Many thanks for your thoughts

ChrisDB
 
Back
Top