I have the following code to exit without saving and entry on a data entry form:
Private Sub Command10_Click()
On Error GoTo Err_Command10_Click
Dim Msg, Response, Style, Title As String
Style = vbYesNo + vbWarning + vbDefaultButton2
Title = "Do you wish to exit"
Msg = "Exiting now will discard changes on the current record. If you wish to save changes click on No then click on the Save. If you wish to exit and disregard changes click on Yes. "
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
'Me.SubBrand.Undo (I tried adding this but had no effect)
Cancel = True
DoCmd.Close
End If
Exit_Command10_Click:
Exit Sub
Err_Command10_Click:
MsgBox Err.DESCRIPTION
Resume Exit_Command10_Click
End Sub
It works fine where the user has not entered data into a field that is required by the table validation but its does not work where the user has enetered everything but then decides they don't want to submitt the record - as I use combo boxes this may happen where they are not sure about a choice but once the combo box is open they are forced to make a choice.
My form is a dataentry form with each control bound to the underlying table.
I want to be able to cancel the entry without the record updating in the table? I have tried adding an undo in one of the fields that is required by the table validation but that did not work.
Cheers
Private Sub Command10_Click()
On Error GoTo Err_Command10_Click
Dim Msg, Response, Style, Title As String
Style = vbYesNo + vbWarning + vbDefaultButton2
Title = "Do you wish to exit"
Msg = "Exiting now will discard changes on the current record. If you wish to save changes click on No then click on the Save. If you wish to exit and disregard changes click on Yes. "
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
'Me.SubBrand.Undo (I tried adding this but had no effect)
Cancel = True
DoCmd.Close
End If
Exit_Command10_Click:
Exit Sub
Err_Command10_Click:
MsgBox Err.DESCRIPTION
Resume Exit_Command10_Click
End Sub
It works fine where the user has not entered data into a field that is required by the table validation but its does not work where the user has enetered everything but then decides they don't want to submitt the record - as I use combo boxes this may happen where they are not sure about a choice but once the combo box is open they are forced to make a choice.
My form is a dataentry form with each control bound to the underlying table.
I want to be able to cancel the entry without the record updating in the table? I have tried adding an undo in one of the fields that is required by the table validation but that did not work.
Cheers