I have a form with a subform.

The user puts information into the main form, and then the sub form is for pass numbers, the pass numbers are tied to the main forms information by child/parent relationship.

I have a save button.

however if the use exits, i would like a save prompt, if the user chooses not to save, i would like the record deleted. Right now it asks and if the user says no dont save and it says its deleting the record, however if you go to the log, the record is there. Im assuming its not deleting the subform data....

Here is the code im using on close.

Dim strMsg As String
Dim iResponse As Integer

' Specify the message to display.
strMsg = "Do you wish to save the changes?" & Chr(10)
strMsg = strMsg & "Click Yes to Save or No to Discard changes."

' Display the message box.
iResponse = MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?")

' Check the user's response.
If iResponse = vbNo Then

' Undo the change.
DoCmd.RunCommand acCmdUndo

' Cancel the update.
Cancel = True

End If

is there a way to delete and or save all records from both main form and sub form?