Why does exit event triggers when control is clicked?

ShieBoon

Board Regular
Joined
May 3, 2011
Messages
111
Hi all, I have a userform, with textboxes within to accept input from users. In the exit events of these textboxes, i do data validation.

When the data entered by user is not valid, i prompt a messagebox and set the cancel property of the exit event to true.

As i test my application, i play around with the controls.
Thing is, i am puzzled why the exit event is triggered even when the control is clicked, and this cause the messagebox to appear 2 times. It is pretty irritating and i wish to get rid of it.

Could anybody kindly explain to me what exactly triggers the exit event?

Any ideas?

Thanks alot

Excel 2003
Shie Boon
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Exit triggers when you leave the control.
If you want to validate data use BeforeUpdate instead, which only triggers if you have edited a control (and before you try to leave it)

Denis
 
Upvote 0
Exit triggers when you leave the control.
If you want to validate data use BeforeUpdate instead, which only triggers if you have edited a control (and before you try to leave it)

Denis

Hi Denis,

Thanks for the feedback. I will try beforeupdate :)

Anw, does exit event only triggers when leaving the control? Because i was in step into mode, and exit event triggers when i enter the control too.
 
Upvote 0
Are you sure it wasn't the exit event of another control?
 
Upvote 0
Hey Denis, right now i'm using beforeupdate as validation. However, the event seems to trigger twice when i click another control in another frame of the form. Any idea why?
 
Upvote 0
Are you only using BeforeUpdate? or Exit as well? If so, stop the Exit code from running. The event should only fire once.

Denis
 
Upvote 0
Alright Denis, i figured it out. Like what rorya said, the exit event was of another control. Many controls in my form. Got mixed up. My apologies.

Thanks for all the feedback anyway :)
 
Upvote 0
I am having issues with the Exit event as well. I have a user form with 3 frames. Inside each frame are text boxes and combo boxes. The first field in the 3rd frame is a combo box. I am using an Exit event to check the data entered (it is one of two exit events in this user form). This exit event gets triggered anytime I click in the other fields within the 3rd frame, even if I am not exiting the field with the exit event (for example, the first field in the first frame is selected; I click on the 2nd field in the 3rd frame and the exit event for the 1st field in the 3rd frame fires). This does not make sense. If I am not exiting the field with the exit event then it should not be triggered. Seems like VBA assumes that field is exited anytime a field that is below it in the tab order is selected. This is not the first time I have had issues with the Exit event. At this point I will avoid using it because it does not work the way I expect.
 
Upvote 0
Why would you expect the event not to fire when you select another control? You have just exited the first control.
 
Upvote 0

Forum statistics

Threads
1,215,444
Messages
6,124,891
Members
449,194
Latest member
JayEggleton

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top