sue gray wrote:
[Quoted Text] >I have a main form that has a command button to open a form in data entry >mode. The form I am opening has entry fields at the top of the form and 4 >subforms - set up as pages in the middle. > >My tables are tblclient, with clientid as primary key and autonumbered. and >tbltxplanmh with txplanMHID as primary key and autonumbered. clientid is a >foreign key in tbltxplanmh. > >The problem I am having is when I click the command button the form opens in >entry mode and I can fill out the top entry fields, but the subforms (pages) >are blank boxes. > >I have given as much info as I can think of, I hope I haven't confused >anyone too much. Thanks for any help. HEre's the command button code: > > >Private Sub AddTxPlan_MH_Click() >' This code adds a new tx plan based on client id. >On Error GoTo Err_AddTxPlan_MH_Click > > Dim strDocName As String > > strDocName = "frmTxPlanMH" > > DoCmd.OpenForm strDocName, , , , acAdd, , Me!clientid > > If IsNull(Forms!frmtxplanmh!clientid) Then > Forms!frmtxplanmh!clientid = Me!clientid > Forms!frmtxplanmh!ContactType.SetFocus > End If >
Make sure the subform control's Link Master/Child properties are set to the ClientID field.
You have probably alreasy done that, so I also think you chould set the ClientID in the form's Load event instead of in the calling form. This should be easy since you are already passing the ClientID in OpenArgs:
If IsNull(Me!clientid) Then Me!clientid = Me.OpenArgs Me!ContactType.SetFocus End If
-- Marsh MVP [MS Access]
|