T
Terri
I am baffled about this! I'm Using Access 2002. Have a form (frm1), based
on tbl1. Another form, frm2, is also based on tbl1, and has a subform on it
which is based on tbl2. tbl2 is in a many-to-one relationship with tbl1.
The primary key in tbl1 is SamplingID, in tbl2 it is SamplingID and MachineNo.
I'm trying to open frm2, with the subform open to a new record. The
samplingID from frm1 is the SamplingID being opened in frm2. I want to add a
new record to the subform (tbl2), with an incremented MachineNo.
What is happening is that, instead of a new subform record, the subform is
opening to the second (if there are 2+ records) record for this SamplingID,
and overwriting the MachineNo with the new MachineNo.
Here is code in the OnOpen event of frm2. I used an OpenArgs statement in
frm1, to open frm2, which includes the incremented MachineNo field:
ElseIf Len(Me.OpenArgs) > 1 Then 'add new record with pre-set MachineNo
strSamplingID = Forms!frm1!SamplingID
Me.SamplingID = strSamplingID
Me.DataFileName = strDataFileName
Me.frm2Sub.SetFocus
DoCmd.GoToRecord , , acNewRec
Me.frm2Sub.Form!SamplingID = strSamplingID
strMachineNo = Right(OpenArgs, 1)
Me.frmWaveCorderInfoSub.Form!MachineNo = strMachineNo
End If
I hope this makes sense - I appreciate any help! Terri
on tbl1. Another form, frm2, is also based on tbl1, and has a subform on it
which is based on tbl2. tbl2 is in a many-to-one relationship with tbl1.
The primary key in tbl1 is SamplingID, in tbl2 it is SamplingID and MachineNo.
I'm trying to open frm2, with the subform open to a new record. The
samplingID from frm1 is the SamplingID being opened in frm2. I want to add a
new record to the subform (tbl2), with an incremented MachineNo.
What is happening is that, instead of a new subform record, the subform is
opening to the second (if there are 2+ records) record for this SamplingID,
and overwriting the MachineNo with the new MachineNo.
Here is code in the OnOpen event of frm2. I used an OpenArgs statement in
frm1, to open frm2, which includes the incremented MachineNo field:
ElseIf Len(Me.OpenArgs) > 1 Then 'add new record with pre-set MachineNo
strSamplingID = Forms!frm1!SamplingID
Me.SamplingID = strSamplingID
Me.DataFileName = strDataFileName
Me.frm2Sub.SetFocus
DoCmd.GoToRecord , , acNewRec
Me.frm2Sub.Form!SamplingID = strSamplingID
strMachineNo = Right(OpenArgs, 1)
Me.frmWaveCorderInfoSub.Form!MachineNo = strMachineNo
End If
I hope this makes sense - I appreciate any help! Terri