Connie-
You should be doing any validation checking in the BeforeUpdate event, not
AfterUpdate. If information is missing, you can set Cancel = True to halt the
update. But that still wouldn't solve your problem of the MsgBox appearing as
the form is being closed.
When you talk about the "close" button, do you mean the Windows close button (X)
or a command button you have provided? If a command button, you have a bit more
control because you can force a save and trap any error created by setting
Cancel = True in BeforeUpdate. If the X button is what is being used, you can
set a module variable in the Close event of the form and perhaps even cancel the
close in the Unload event.
Just FYI, the events happen in this sequence for a form:
BeforeUpdate (can cancel)
AfterUpdate
Unload (can cancel)
Close
So, BeforeUpdate can set a flag to say it has cancelled the update, and Unload
can look at that flag to cancel the close of the form.
John Viescas, author
Microsoft Office Access 2010 Inside Out
Microsoft Office Access 2007 Inside Out
Building Microsoft Access Applications
Microsoft Office Access 2003 Inside Out
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)
--------------------------------------
From: MS_Access_Professionals@yahoogroups.com
[mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of mrsgoudge
Sent: Wednesday, May 30, 2012 9:50 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Re: Testing to see if any message boxes are open
Bill,
I have once again encountered that when I use the Close button on the Sold form
(when the control was last in a subform), if the subform's AfterUpdate event
results in a message reminding the user that they might need to add certain
info, the close event for the main form still closes anyways.
Therefore I was wondering if there was another way around this problem. Perhaps
looking to see if the msgbox was open.
Now I'm wondering if it would work to set a variable before the subform's
opening of the msgbox and when I click on the Close button on the main form have
it first check to see if the variable is true and if so exit sub.
Would that work?
Connie
--- In MS_Access_Professionals@yahoogroups.com, "Bill Mosca" <wrmosca@...>
wrote:
>
> Connie -
>
> MsgBoxes are always modal. You can't do anything when they are open and your
code pauses until the user responds.
>
> Therefore, you can't test to see if any are open. You're stuck at a standstill
until the box is closed.
>
> Can you give us a reason as to why you would want to do this?
>
> Bill Mosca
>
> --- In MS_Access_Professionals@yahoogroups.com, mrsgoudge <no_reply@> wrote:
> >
> > Good afternoon/evening! Is there a way to test if any message boxes are
open?
> >
> > thanks!
> > Connie
> >
>
Rabu, 30 Mei 2012
RE: [MS_AccessPros] Re: Testing to see if any message boxes are open
__._,_.___
.
__,_._,___
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar