Hi Pete
If you have users who find this message mildly annoying, ask them whether
they would prefer Access to just silently lose their entry without telling
them. Microsoft is giving them the choice: they can go back and fix the
entry, or throw the entry away and get out of there. That's a pretty useful
choice.
They only get that choice if they try to close the form when it contains an
unsavable entry. You can try to work around that by disabling the Close
button on the form, building a custom menu so they can't choose Close from
the File menu or switch views from the View menu, or apply a filter or sort
from the Records menu, apply a custom toolbar to remove all the problem
buttons, reprogram the keystrokes such as Ctrl+F4 and Alt+F4 with an
AutoKeys macros, and run API calls to remove the close button from the main
Access window.
Or you could programmatically set module-level flags that let you cancel the
UnLoad event of the form and generate even more annoying message boxes and
end up corrupting the database as frustrated users who can't get out of
their form terminate Access with the Windows Task Manager or by switching
off their database.
Or, you could add a Cancel button to your form to give them another way out:
If Me.Dirty Then Me.Undo
DoCmd.Close acForm, Me.Name
BTW, there is a serious bug with the Close action that *does* cause it to
silently lose what the user entered if it cannot be saved:
http://allenbrowne.com/bug-01.html
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Paul Brady" <pt*****@aol.com> wrote in message
news:2c********************************@4ax.com...
I have non-computer skilled users entering data into a form. There
are certain ranges of values which, if they enter them, make no sense
in the application, but I can't test them until they try to close out
the form, in which case I can look at the entire set of values and see
if they're OK. So, I have this code.
for the "Before Update" event:
if (their variables are inappropriate) then
msgbox "You've entered bad variables (or some such message),
go back and fix them", vbexclamation
cancel = true
end if
end sub
This works fine, except that the user gets the following message
(which I want suppressed):
"You can't change the record at this time. If you close this object
now, all the data changes you have made will be lost. Do you want to
close the databases object anyway?"
YES NO
The default is "yes," which I don't want them to get.
I don't want them to get this message, because it happens rarely and
the users don't understand it. I just want my "cancel=true" statement
to kill the update process and return them to the form, without any
further word from Bill Gates. How do I do that?
Thanks. Pete Brady