on exit field

  • Thread starter Thread starter peter
  • Start date Start date
P

peter

Hi,
On a user form, I have a field that fires "on exit". if the cursor is in
this field when a command button is clicked, the code for the on exit runs,
not the code for the button clicked. the button code is "on click".
Is there some way to know what button is clicked so the on exit code could
test for the click?
Is there some trick to get the cursor out of the field without firing the
code?
any help or ideas would be greatly appreciated.

peter
 
Hi Peter,

I don't think you are going to prevent the On Exit event firing. You can
only include code within the On Exit event sub to exit the sub under
specified conditions.

Perhaps you can tell us why you don't want the event to fire and why you
need to click a command button without running the On Exit code. The reason I
ask this is because I have used the Double Click event to call a procedure
such as add items to a combo box so if it is some code you want to run before
exiting the field then maybe that is the way to go.
 
Just use a module scope Boolean which you test in the OnExit procedure, and
set that Boolean as required.
 
Is this commandbutton the Cancel button of the userform?

If yes, then you could change its .takefocusonclick property to False (either in
the userform_initialize procedure or manually in the properties window).
 

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

Back
Top