Use the form's Before Update event and then you can do things like:
Dim blnFlag As Boolean
If IsNull(Me.MyTextBox) Or Me.MyTextBox = "" Then
blnFlag = True
End If
If IsNull(Me.MyComboBox) Then
blnFlag = True
End If
If blnFlag Then
If MsgBox( "You have not filled out the form completely. Do you want to
continue filling it out?, vbQuestion + vbYesNo, "Incomplete Form") = vbNo Then
Cancel = True
Me.Undo
End If
And that will cancel the update and clear the form if they don't want to
continue, but if they do then it will save the record (nothing needed to do
that).
In the command button to close the form just use
DoCmd.Close acForm, Me.Name, acSaveNo
You can use that as written (no changes necessary) as the Me.Name just
references the current form name without you having to type it. And the
acSaveNo part refers to DESIGN CHANGES on the form, not the record. The
record will be saved if they choose Yes from the message box.
--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at
http://www.btabdevelopment.com
__________________________________
If my post was helpful to you, please rate the post.