Re: Having to click Ok twice to clear message box
- From: Tim Ferguson <FergusonTG@xxxxxxxxxxxx>
- Date: Wed, 08 Mar 2006 09:53:52 -0800
"graeme34 via AccessMonster.com" <u18757@uwe> wrote in
5cea163b4fd92@uwe:">news:5cea163b4fd92@uwe:
But TestRecordEntered is called from seven command buttons (up to now
and still under development) so its making the coding look a bit
messy. But if its the only way to prevent the 'superfluous Exit event
' as you called it then I'll have to live with the extra lines of
code.....unless you know of another way without having to first save
the field to be able to use the setfocus method in the before update
event. Even taking out the Setfocus method line the msgbox still
appeared twice. Looks like I'll just have to repeat my code in each on
click event :(
I can't immediately see why a commandButton_Click event should cause a
big problem... but from here I cannot see how all your interdependencies
work. One thing to do is to breakpoint the MsgBox line, and inspect the
Call Stack to see why the code is being run twice. Are you sure it's the
same line of code both times?
Having said that, it's nicer for the user to avoid error messages than to
respond to them. That is why I'd be validating this thing up front:
private sub TestRecordEntered_BeforeUpdate(cancel as integer)
if len(testrecordentered.text) = 0 then
' empty value is not allowed
cancel = true
elseif not isnumeric(testrecordentered.text) then
' no good either
cancel = true
elseif dcount("*", "Orders", _
"OrderNum = " & testrecordentered.text) = 0 Then
msgbox "This is not a valid order!"
cancel = true
else
' not strictly necessary
cancel = false
end if
end sub
-- although you do need to recheck when actually using the value, because
the user will bypass the BeforeUpdate if he or she does not actually
change the text box, most problems are already gone.
Not much of an answer, I'm afraid, but hope it helps anyway.
All the best
Tim F
.
- Follow-Ups:
- Re: Having to click Ok twice to clear message box
- From: graeme34 via AccessMonster.com
- Re: Having to click Ok twice to clear message box
- References:
- Having to click Ok twice to clear message box
- From: graeme34 via AccessMonster.com
- Re: Having to click Ok twice to clear message box
- From: Tim Ferguson
- Re: Having to click Ok twice to clear message box
- From: graeme34 via AccessMonster.com
- Having to click Ok twice to clear message box
- Prev by Date: Re: supress "error"
- Next by Date: Re: Having to click Ok twice to clear message box
- Previous by thread: Re: Having to click Ok twice to clear message box
- Next by thread: Re: Having to click Ok twice to clear message box
- Index(es):