N
NH
I have a form which has two buttons at the bottom:
OK (check fields have been filled in correctly and close
form)
and a Cancel (undo current record, and close form)
These work perfectly, but it doesn't stop users from
hitting the X on the title bar and bypassing the checks..
I have moved the checks to the Form_Unload event, and set
the button to just close the form (because the checks will
be made as the form closes), but now I get a
message 'Close action was cancelled' when the button is
pressed..
I have attached a snippet of the code:
Prvate Sub BtnCloseForm_btn_Click()
DoCmd.Close , , acSaveYes
End Sub
Private Sub Form_Unload(Cancel As Integer)
If Me.NewRecord = True And Me.Dirty = False Then Exit Sub
'<Run Checks>
If strChecksPassed = True Then Exit Sub
'<Inform user of mistakes>
Cancel = True
End Sub
I think I understand why it is cancelling the close
command, but I can't think of any way to get around it..
Can someone suggest a way?
Thank you
NH
OK (check fields have been filled in correctly and close
form)
and a Cancel (undo current record, and close form)
These work perfectly, but it doesn't stop users from
hitting the X on the title bar and bypassing the checks..
I have moved the checks to the Form_Unload event, and set
the button to just close the form (because the checks will
be made as the form closes), but now I get a
message 'Close action was cancelled' when the button is
pressed..
I have attached a snippet of the code:
Prvate Sub BtnCloseForm_btn_Click()
DoCmd.Close , , acSaveYes
End Sub
Private Sub Form_Unload(Cancel As Integer)
If Me.NewRecord = True And Me.Dirty = False Then Exit Sub
'<Run Checks>
If strChecksPassed = True Then Exit Sub
'<Inform user of mistakes>
Cancel = True
End Sub
I think I understand why it is cancelling the close
command, but I can't think of any way to get around it..
Can someone suggest a way?
Thank you
NH