AfterUpdate event - determining button clicked 
Author Message
 AfterUpdate event - determining button clicked

I have a UserForm with a number of textboxes.  Per my users' request, as
they enter data in a textbox and then move on (either by tab or mouse
click), they want the data to be validated. This is easy - I use an
AfterUpdate event. However, if the button clicked is the Cancel button,
then I do not want to perform the validation for that textbox.

Is there a way to easily determine which button has been clicked inside
of an AfterUpdate event? I realize that there is a Click event for the
Cancel button but it does not fire until after the AfterUpdate event.

Can I find out what events are pending?? Is there any documentation as
to event precedence?

Thanks for any help,
Dominic



Fri, 14 Jan 2000 03:00:00 GMT  
 AfterUpdate event - determining button clicked

On Mon, 28 Jul 1997 22:51:03 -0500, "Dominic J. Koorie"

Quote:

>I have a UserForm with a number of textboxes.  Per my users' request, as
>they enter data in a textbox and then move on (either by tab or mouse
>click), they want the data to be validated. This is easy - I use an
>AfterUpdate event. However, if the button clicked is the Cancel button,
>then I do not want to perform the validation for that textbox.

>Is there a way to easily determine which button has been clicked inside
>of an AfterUpdate event? I realize that there is a Click event for the
>Cancel button but it does not fire until after the AfterUpdate event.

I haven't tried this, but how about putting an
Application.OnTime Now, "'CheckABox " & Me.ActiveControl.Name & "'"
in the testbox AfterUpdate handler.

This should result in CheckABox being run after any other pending
events.

Then the Cancel button handler could set a global flag before
CheckABox ran and CheckABox could test that flag and only proceed with
the validation if cancel had not been used.

Let us know if it works.

Bill Manville
Oxford, England
Microsoft Excel - MVP



Sat, 15 Jan 2000 03:00:00 GMT  
 AfterUpdate event - determining button clicked

Quote:

> On Mon, 28 Jul 1997 22:51:03 -0500, "Dominic J. Koorie"

> >I have a UserForm with a number of textboxes.  Per my users' request, as
> >they enter data in a textbox and then move on (either by tab or mouse
> >click), they want the data to be validated. This is easy - I use an
> >AfterUpdate event. However, if the button clicked is the Cancel button,
> >then I do not want to perform the validation for that textbox.

> >Is there a way to easily determine which button has been clicked inside
> >of an AfterUpdate event? I realize that there is a Click event for the
> >Cancel button but it does not fire until after the AfterUpdate event.

> I haven't tried this, but how about putting an
> Application.OnTime Now, "'CheckABox " & Me.ActiveControl.Name & "'"
> in the testbox AfterUpdate handler.

> This should result in CheckABox being run after any other pending
> events.

> Then the Cancel button handler could set a global flag before
> CheckABox ran and CheckABox could test that flag and only proceed with
> the validation if cancel had not been used.

> Let us know if it works.

> Bill Manville
> Oxford, England
> Microsoft Excel - MVP

Bill,

Your solutions does and does not work. If I just code
'Application.OnTime Now', then the CheckABox routine runs before the
Cancel button click event. If I code 'Application.OnTime
Now+TimeValue("00:00:01")', then the Cancel event occurs before then
CheckABox routine. However, there is a delay after the Cancel button is
clicked. Close but no cigar....

Thanks for your help

Dominic J Koorie



Fri, 21 Jan 2000 03:00:00 GMT  
 AfterUpdate event - determining button clicked


Quote:
>Bill,
>Your solutions does and does not work. If I just code
>'Application.OnTime Now', then the CheckABox routine runs before the
>Cancel button click event.

Thanks, that's interesting.

Quote:
>If I code 'Application.OnTime Now+TimeValue("00:00:01")', then the Cancel event occurs before then
>CheckABox routine. However, there is a delay after the Cancel button is
>clicked.

How about

Application.OnTime Now+TimeValue("00:00:01")/100  
or similar?

--
Bill Manville
Oxford, England
Microsoft MVP - Excel



Fri, 21 Jan 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. AfterUpdate event doesn't work after clicking save icon in toolbar

2. Code from AfterUpdate vs Click on button

3. beforeupdate event and button click event collision

4. Control Exit event kills Button Click Event in Access2002 Forms

5. Handling KeyDown event to fire a command button Click event

6. Determine which mouse button was clicked

7. Determining check button was clicked on the navigation bar

8. disabling the double click event for userform buttons

9. Change the state of a toggle button without running the click event

10. Repost: (workaround no good) Change the state of a toggle button without running the click event


 
Powered by phpBB® Forum Software © phpBB Group