G
Guest
I have a form with a subform; Each parent record (main form) should have at
least one child record, but can have many. Referential integrity is
established in the Relationships table. I want to check/require that a child
record exists in the subform before the main form can be closed. If one does
not exist, I want the form to remain open and to generate a msgbox to tell
the user they must add a child record before closing the form.
Don't know if this will matter or not, but users asked for a confirmation
dialog upon closing the form, so I currently have the following code in
beforeUpdate:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
strMsg = "Data has changed."
strMsg = strMsg & " Save Changes?"
If MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?") = vbYes Then
'do nothing
Else
DoCmd.RunCommand acCmdUndo
End If
End Sub
Any help would be appreciated. I Thought this would be very easy but have
not figured it out nor seen a posting about this
least one child record, but can have many. Referential integrity is
established in the Relationships table. I want to check/require that a child
record exists in the subform before the main form can be closed. If one does
not exist, I want the form to remain open and to generate a msgbox to tell
the user they must add a child record before closing the form.
Don't know if this will matter or not, but users asked for a confirmation
dialog upon closing the form, so I currently have the following code in
beforeUpdate:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
strMsg = "Data has changed."
strMsg = strMsg & " Save Changes?"
If MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?") = vbYes Then
'do nothing
Else
DoCmd.RunCommand acCmdUndo
End If
End Sub
Any help would be appreciated. I Thought this would be very easy but have
not figured it out nor seen a posting about this