Access 2003 Click Event not firing first time.

S

Slick Willy

I have some Command Buttons on a form with several tabbed subforms. If
I click the Command Button once the screen flickers, but the event
does not fire. If I click a button a second time it does fire. I've
tried debugging the event but the code is never reached. I've rebuilt
the form and tried adding a new button, but the result is the same. If
I put the code in the On Enter event it fires the first time.

I'll try playing with the initial focus, but any ideas/workarounds
appreciated.
 
K

Ken Snell MVP

Are the command buttons in a subform? That behavior can occur in these
situations, as the subform first must get the focus and then the command
button can get the focus -- a two-step process.
 
S

Slick Willy

Are the command buttons in a subform? That behavior can occur in these
situations, as the subform first must get the focus and then the command
button can get the focus -- a two-step process.
No, The Command buttons are on the Main form. If I call the Click
Event from the Got Focus event it works. I have to put a stop in the
Focus event to see what's happening, but I suspect it's just quiting.
I had a timer, but turning it off had no effect. I also went throught
to make sure all my Error code was set to zero at the end of each
call, but this did not turn anything up either.
 
S

Slick Willy

No, The Command buttons are on the Main form. If I call the Click
Event from the Got Focus event it works. I have to put a stop in the
Focus event to see what's happening, but I suspect it's just quiting.
I had a timer, but turning it off had no effect. I also went throught
to make sure all my Error code was set to zero at the end of each
call, but this did not turn anything up either.

I just realized the that the Form Load Event is not firing either. The
Form Load fires on the first click to the form and then the Click
Event fires on the second click.
 
K

Ken Snell MVP

Let's see all the code in the form's module. Some event is causing a loss of
focus from the button or form for the first click.

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/


On Apr 11, 3:44 pm, "Ken Snell MVP" <[email protected]>
wrote:> Are the command buttons in a subform? That behavior can occur in
these

No, The Command buttons are on the Main form. If I call the Click
Event from the Got Focus event it works. I have to put a stop in the
Focus event to see what's happening, but I suspect it's just quiting.
I had a timer, but turning it off had no effect. I also went throught
to make sure all my Error code was set to zero at the end of each
call, but this did not turn anything up either.

I just realized the that the Form Load Event is not firing either. The
Form Load fires on the first click to the form and then the Click
Event fires on the second click.
 
S

Slick Willy

Let's see all the code in the form's module. Someeventis causing a loss of
focus from the button or form for the firstclick.

--

        Ken Snell
<MS ACCESS MVP>http://www.accessmvp.com/KDSnell/





I just realized the that the Form LoadEventis not firing either. The
Form Load fires on the firstclickto the form and then theClickEventfires on the secondclick.- Hide quoted text -

- Show quoted text -

Yeah, I was thinking it's a focus problem too. So I went through all
of the set focus events in the subforms. Once I changed the set focus
in the subform to the parent form it all loads. But the command
buttons disable themselves and some other buttons when clicked
depending on the operation. So I have to be careful what has the focus
when clicking a particular button. I ended up checking to see if the
main form is loaded and setting focus to the form if not loaded,
otherwise I set the focus to a command button that won't get disabled
during that particular event.

Thanks for the help.
 
K

Ken Snell MVP

You can check the Enabled property of a control before you try to set focus
to it. If Enabled property is True, then it can receive the focus.
--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/


Let's see all the code in the form's module. Someeventis causing a loss of
focus from the button or form for the firstclick.

--

Ken Snell
<MS ACCESS MVP>http://www.accessmvp.com/KDSnell/





I just realized the that the Form LoadEventis not firing either. The
Form Load fires on the firstclickto the form and then theClickEventfires
on the secondclick.- Hide quoted text -

- Show quoted text -

Yeah, I was thinking it's a focus problem too. So I went through all
of the set focus events in the subforms. Once I changed the set focus
in the subform to the parent form it all loads. But the command
buttons disable themselves and some other buttons when clicked
depending on the operation. So I have to be careful what has the focus
when clicking a particular button. I ended up checking to see if the
main form is loaded and setting focus to the form if not loaded,
otherwise I set the focus to a command button that won't get disabled
during that particular event.

Thanks for the help.
 

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