Control Exit event kills Button Click Event in Access2002 Forms

M

Mike Elliott

Access 2002 Forms behave differently than Access 97 Forms.

ControlA has the Focus and I click ButtonB. If there is an Exit event for
ControlA, it will Fire, but the Click Event procedure for Button B never
fires.

In Access 97, The Exit Event would have fired and then the Click event for
the button would fire.

My workaround was to use the Change event where possible and not the Exit or
LostFocus events.
 
D

Dan Artuso

Hi,
That definitely is not happening in my version of 2002.
The usual happens:
Exit event
Click event

Could it be something in your code?
 
D

Dirk Goldgar

Mike Elliott said:
Access 2002 Forms behave differently than Access 97 Forms.

ControlA has the Focus and I click ButtonB. If there is an Exit
event for ControlA, it will Fire, but the Click Event procedure for
Button B never fires.

In Access 97, The Exit Event would have fired and then the Click
event for the button would fire.

My workaround was to use the Change event where possible and not the
Exit or LostFocus events.

I'm using Access 2002, and I don't see the misbehavior you describe.
Are you sure you aren't doing something in the Exit event for ControlA
that would prevent ButtonB from receiving the click? Canceling the
event, perhaps?
 
M

Mike Elliott

I left out an important detail. The Exit procedure determines which field to
move to next. The DoCmd.GotoControl statement in the Exit procedure moves
the focus to a third control.

This causes a problem because users have to Click the button multiple times.
Each click fires the "Exit" Event for whichever control has the focus. When
they get to a control with no Exit event, then the Click event for the button
will fire.

I created a new form to test this with. I dropped 3 fields onto it as well
as a command button. The Exit event for the first field moves to the third
field. The Button just displays a message.

When I click the button, the focus moves to field 3. When I click it again,
my message is displayed. If I select the second field (with no exit event)
and click the button, my message displays immediately.

However, I then went back and tested this simple form in Access97 and it
behaves exactly the same way. I had never noticed this behavior before. I
was wrong earlier when I said that they behaved differently. I should have
done the simple test in both versions before posting the question.

I appreciate the quick responses and hope I have not wasted your time.
Mike
 
D

Dirk Goldgar

Mike Elliott said:
I left out an important detail. The Exit procedure determines which
field to move to next. The DoCmd.GotoControl statement in the Exit
procedure moves the focus to a third control.

This causes a problem because users have to Click the button multiple
times. Each click fires the "Exit" Event for whichever control has
the focus. When they get to a control with no Exit event, then the
Click event for the button will fire.

That makes sense. The focus has to get to the button before it can
receive the mouse click, and you're preventing it from getting there.

If you need to find a way to work around this, I'd guess you need to
move the focus-shifting code out of the Exit event of that control, and
put it either in the button itself (if that makes sense in the context
of what you're trying to do), or in the GotFocus or Enter event of a
control that you place next in the tab order. But the specifics will
depend on what you're trying to do.

Good luck.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top