D
David F
If I have an existing child record then the child form opens to the proper
child record and all is well. If not, the child form opens to a blank record
and when I try to save it I get the message: You cannot add or change a
record becuase a related record is required in table 'order'.
The relation between the two tables "order" and "orderfile" is one-to-one.
The code behind the click event in the "order" (parent) form is:
Private Sub View_Script_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "f_order_file"
'save the current record to make sure ID exists
DoCmd.RunCommand acCmdSaveRecord
stLinkCriteria = "[orderid]=" & Me![orderid]
DoCmd.OpenForm stDocName, , , stLinkCriteria, , , Me![name]
End Sub
The code behind the "orderfile" form (child) load event looks like this:
Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
[txtName] = Me.OpenArgs
End If
End Sub
The always name is passed to the child form but if a "orderfile" (child)
record does not already exist, no orderid is passed and I cannot save the
new child record I try to create.
How do I reference the order ID passed to the form so I can create a new
child record?
child record and all is well. If not, the child form opens to a blank record
and when I try to save it I get the message: You cannot add or change a
record becuase a related record is required in table 'order'.
The relation between the two tables "order" and "orderfile" is one-to-one.
The code behind the click event in the "order" (parent) form is:
Private Sub View_Script_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "f_order_file"
'save the current record to make sure ID exists
DoCmd.RunCommand acCmdSaveRecord
stLinkCriteria = "[orderid]=" & Me![orderid]
DoCmd.OpenForm stDocName, , , stLinkCriteria, , , Me![name]
End Sub
The code behind the "orderfile" form (child) load event looks like this:
Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
[txtName] = Me.OpenArgs
End If
End Sub
The always name is passed to the child form but if a "orderfile" (child)
record does not already exist, no orderid is passed and I cannot save the
new child record I try to create.
How do I reference the order ID passed to the form so I can create a new
child record?