I have a form which users complete to submit a service request. The completed fields are saved to a table. As soon as users started completing the form, a new record is saved in the table.
I would like to code it such that if they close the window (or possibly click a 'cancel' button'), the newly created record will be deleted but all the other records remain.
I tried the following:
This only words however is the user starts completing the form and thus a new record is completed. If they open the form, don't change anything, and then close it, no new record is created and the code deletes the most recent record.
Any suggestions?
And thank you in advance to everyone who contributes to this site... I have already found many useful suggestions and solutions. A wonderful learning tool.
I would like to code it such that if they close the window (or possibly click a 'cancel' button'), the newly created record will be deleted but all the other records remain.
I tried the following:
Code:
Private Sub Form_Unload(Cancel as Integer)
If MsgBox("Cancel Service Request?", vbYesNo) = vbYes Then
MsgBox "Your Service Request has not been submitted."
DoCmd.GoToRecord , , acLast
DoCmd.RunCommand acCmdDeleteRecord
Else
Exit Sub
End If
End Sub
This only words however is the user starts completing the form and thus a new record is completed. If they open the form, don't change anything, and then close it, no new record is created and the code deletes the most recent record.
Any suggestions?
And thank you in advance to everyone who contributes to this site... I have already found many useful suggestions and solutions. A wonderful learning tool.