G
Guest
Hello all,
I am using a command button on a form to open another form.
The first form (frm_Orders) is bound to tbl_Orders. The 2nd
(frm_OrderErrors) is bound to tbl_OrderErrors. tbl_Orders is related in a 1
to 1 relationship to tbl_OrderErrors using RecordID.
The relationship is set to enforce referential integrity, with cascading
updates & deletes.
On the OnClick event of the command button I want to do one of two things:
If there is already an error record for this order:
Open the frm_OrderErrors where the RecordID matches the RecordID of
frm_Orders
Otherwise, start a new record with the RecordID of frm_OrderErrors set to
match the RecordID of frm_Orders.
I have tried various combinations of:
-----------------------------------
On the command Button
-----------------------------------
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frm_OrderErrors"
stLinkCriteria = "[RecordID]=" & Me![RecordID]
DoCmd.OpenForm stDocName, , , stLinkCriteria, , , Me.RecordID
-----------------------------------
On the Form Load Event of frm_OrderErrors
-----------------------------------
If Me.Recordset.RecordCount = 0 Then
DoCmd.RunSQL "INSERT INTO
tbl_OrderErrors([RecordID])VALUES(Forms!frm_Orders!RecordID)"
End If
-----------------------------------
On the Form Open Event of frm_OrderErrors
-----------------------------------
If Me.Recordset.RecordCount = 0 Then
DoCmd.GoToRecord, , acNewRec
End If
Any suggestions would be greatly appreciated!
Thank you,
Renee
I am using a command button on a form to open another form.
The first form (frm_Orders) is bound to tbl_Orders. The 2nd
(frm_OrderErrors) is bound to tbl_OrderErrors. tbl_Orders is related in a 1
to 1 relationship to tbl_OrderErrors using RecordID.
The relationship is set to enforce referential integrity, with cascading
updates & deletes.
On the OnClick event of the command button I want to do one of two things:
If there is already an error record for this order:
Open the frm_OrderErrors where the RecordID matches the RecordID of
frm_Orders
Otherwise, start a new record with the RecordID of frm_OrderErrors set to
match the RecordID of frm_Orders.
I have tried various combinations of:
-----------------------------------
On the command Button
-----------------------------------
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frm_OrderErrors"
stLinkCriteria = "[RecordID]=" & Me![RecordID]
DoCmd.OpenForm stDocName, , , stLinkCriteria, , , Me.RecordID
-----------------------------------
On the Form Load Event of frm_OrderErrors
-----------------------------------
If Me.Recordset.RecordCount = 0 Then
DoCmd.RunSQL "INSERT INTO
tbl_OrderErrors([RecordID])VALUES(Forms!frm_Orders!RecordID)"
End If
-----------------------------------
On the Form Open Event of frm_OrderErrors
-----------------------------------
If Me.Recordset.RecordCount = 0 Then
DoCmd.GoToRecord, , acNewRec
End If
Any suggestions would be greatly appreciated!
Thank you,
Renee