PC Review


Reply
Thread Tools Rate Thread

Control Exit event kills Button Click Event in Access2002 Forms

 
 
=?Utf-8?B?TWlrZSBFbGxpb3R0?=
Guest
Posts: n/a
 
      20th Oct 2004
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.
 
Reply With Quote
 
 
 
 
Dan Artuso
Guest
Posts: n/a
 
      20th Oct 2004
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?

--
HTH
-------
Dan Artuso, MVP
"Mike Elliott" <Mike (E-Mail Removed)> wrote in message
news:5F325D6E-F4E4-40B6-A21D-(E-Mail Removed)...
> 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.



 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      20th Oct 2004
"Mike Elliott" <Mike (E-Mail Removed)> wrote in
message news:5F325D6E-F4E4-40B6-A21D-(E-Mail Removed)
> 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?

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


 
Reply With Quote
 
=?Utf-8?B?TWlrZSBFbGxpb3R0?=
Guest
Posts: n/a
 
      20th Oct 2004
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


"Dirk Goldgar" wrote:

> "Mike Elliott" <Mike (E-Mail Removed)> wrote in
> message news:5F325D6E-F4E4-40B6-A21D-(E-Mail Removed)
> > 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?
>
> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com
>
> (please reply to the newsgroup)
>
>
>

 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      20th Oct 2004
"Mike Elliott" <Mike (E-Mail Removed)> wrote in
message news1B77F35-2113-4C28-94EB-(E-Mail Removed)
> 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.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
button click event in a AccordionPane control Sinan Alkan Microsoft ASP .NET 1 24th Sep 2008 02:15 PM
Generate click event in input button in Windows.Forms.WebBrowser c =?Utf-8?B?SmltIE1lYWQ=?= Microsoft C# .NET 2 23rd Nov 2007 07:00 PM
When user press F5 after a button click event, the click event fires again! Max2006 Microsoft ASP .NET 2 19th Sep 2007 06:37 AM
How to raise an event of button (click event) from textbox's onkeydown event? ABC Microsoft Dot NET Framework Forms 2 25th Jul 2006 11:19 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge Microsoft ASP .NET 2 26th May 2004 12:45 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:18 PM.