I believe the following will do what you're asking:
Step 1 - Open the Form's code module and at the very top, just before the
first Sub or Function enter
'This is a Global variable, available to all of the procedures in this
module
Dim OKtoClose as Boolean
Step 2 - Go to the Form's Event Property tab and create an OnDirty event
procedure that sets OKtoClose to False. This event fires as soon as anyone
makes any change that would require a save.
OKtoClose = False
Step 3 - Go to the Form's Event Property tab and create an OnUnload event
procedure that Checks the status of OKtoClose and Cancels the Unload
(Close) if OKtoClose is not True.
If Not OKtoClose then
msgbox "You Need To Press the Save Button Before You Can Close This
Form"
Cancel = True
End if
Step 4 - Go to your Save Button's OnClick event procedure and (after the
DoCmd line) set OKtoClose to True
OKtoClose = True
Warning, as you may know, Access automatically saves as you move from record
to record. This procedure will force the user to press the save button
before they can close the form even if the record may not need saving.
Len Robichaud
"Eric" <er************@gmail.comwrote in message
news:11**********************@b79g2000hse.googlegr oups.com...
Hi,
I have a form that requires a save button to be clicked before closing
the form. I would like a msgbox to pop up when the button is not
clicked before closing. Can someone show me how i would code this?
Thanks!