Why fight the built-in Close button? Just set Close Button and/or Control
Box to No, and make your own button to close the form:
Me.Dirty = False
DoCmd.Close acForm, Me.Name
How are you performing the validation? It doesn't seem to be in the form's
Before Update event, which is the usual place for form-level validation. Or
are you validating at the table level (i.e. setting the Required property of
some fields to Yes)?
I assume the Cancel button has something like:
MyAction = Cancel
Me.Form.Undo
How about the Save button?
McHammer wrote:
It usually helps to post the actual code when there is a question about the
code. Why show them the X button (top right corner, not left, but I assume
[quoted text clipped - 7 lines]
of work for something that doesn't work as well as what you could have with
your own command buttons.
Yes, "X" on the right...
Form is modal popup type, no min/max button, dialog, ctrl box yes.
Here below the code
Public MyAction As Variant
I've added MyAction = "save" to Save button and MyAction = "Cancel" to
Cancel button On click events
Private Sub Form_Current()
MyAction = Null
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
Select Case MyAction
Case "Cancel"
'do nothing
Case "Save"
'do nothing
Case Else
MsgBox "Push Save or Cancel", vbOKOnly
Cancel = True
Exit Sub
End Select
End Sub
In this way, if a new record is entered it's possible to "save & close" the
form or "cancel" a partial unwanted data and then close the form with "X"
button. If you try to close the form with unwanted data through "X" button,
Cancel = True should stop any other event, or at least it was my target.
--
Message posted via
http://www.accessmonster.com