I've reviewed numerous solutions to others with the same error and for some reason I just can't seem to get past my issue... please help!
The objective is to simply verify that a required field has been entered prior to saving/closing the form. If the field is null, it prompts the user for a value. If they click OK or cancel, a secondary prompt asks if the record should be deleted. If they select "No", the code properly loops back to the input request, but if they select "Yes", I get the Runtime error 2501 "The runcommand was cancelled".
All I want it to do is close the active form without saving a record.
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.EquipNumber) Then
Do
InputEq = InputBox("An equipment number is required. Please enter a value:", "Missing Equipment Number")
If InputEq = "" Then
If MsgBox("An Equipment Number is required to save." & vbCrLf & _
"Would you prefer to delete the current record?", vbCritical + vbYesNo, "Delete Record?") = vbYes Then
DoCmd.RunCommand acCmdCloseWindow
End If
End If
Loop Until InputEq <> ""
Me.EquipNumber = InputEq
End If
If IsNull(Me.txtUser) Then
Me.txtUser = Environ$("Username")
Me.txtEnterDate = Date
End If
End Sub
All I want it to do is close the active form without saving a record.
Comment