+ Reply to Thread
Results 1 to 7 of 7

textbox exit event by clicking another control

  1. #1
    Forum Contributor Rhudi's Avatar
    Join Date
    03-08-2013
    Location
    South Carolina, US
    MS-Off Ver
    Professional Plus 2016 aka Office 365
    Posts
    201

    textbox exit event by clicking another control

    I've searched, but I'm not asking Google the correct way...

    I have a text box with an exit event that works just fine.

    If I tab out, the event fires and my code runs. I then click a control and everything works as expected.

    If I do not tab out, and instead click the other control, the exit event still fires just fine, but the clicked control doesn't run. I have to click it again.

    I know this is going to be a simple, ID10T fix. :P

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,979

    Re: textbox exit event by clicking another control

    Probably ... but without the code, perhaps not.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Contributor Rhudi's Avatar
    Join Date
    03-08-2013
    Location
    South Carolina, US
    MS-Off Ver
    Professional Plus 2016 aka Office 365
    Posts
    201

    Re: textbox exit event by clicking another control

    The website won't let me paste the code. It blocks it as a potential SQL Injection attack.

    The code is otherwise straight forward. It's a simple: "Private Sub tunnelAtargetIP_Exit(ByVal Cancel As MSForms.ReturnBoolean)".

    If I tab out, the exit code runs. Then, I can click the next Commandbutton and it runs.

    If I exit the textbox by clicking the Commandbutton, the exit code runs but the Commandbutton_Click code does not. I can click the Commandbutton again and then it does run.

    It seems like, when I click a control, that control_click won't run because the textbox_exit code isn't done yet?

  4. #4
    Valued Forum Contributor
    Join Date
    12-14-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2007
    Posts
    439

    Re: textbox exit event by clicking another control

    Can you show me the textbox exit event code?

  5. #5
    Forum Contributor Rhudi's Avatar
    Join Date
    03-08-2013
    Location
    South Carolina, US
    MS-Off Ver
    Professional Plus 2016 aka Office 365
    Posts
    201

    Re: textbox exit event by clicking another control

    I have duplicated the condition in the most minimal way possible.

    I made a form with a default textbox and a default command button.

    Here is the associated code:
    Please Login or Register  to view this content.
    There is nothing else. No initialize code, nothing.

    Behavior...
    I type "hello" into the textbox and tab out. What I type is displayed as "Exit code: hello".
    I type "hello2" into the textbox and only click commandbutton1. I only see "Exit code: hello2". I do not see the second message.

    Single step through the code, execution is done after the exit code.

    I type "hello2", click the button and only the exit code runs. Click the button again, it does run.


    I have an update where I am playing around...
    This seems to be the direction that I need to go:
    Please Login or Register  to view this content.
    Last edited by Rhudi; 08-29-2019 at 10:18 AM.

  6. #6
    Valued Forum Contributor
    Join Date
    12-14-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2007
    Posts
    439

    Re: textbox exit event by clicking another control

    When the textbox is selected, if you click the button the exit event is triggered and show the message. At that time, the mouse click but the button don't receive the click because the message is showing.
    You can experiment by tab out the textbox, when the message is showing, don't close it and try click the button. You can't click the button to run macro until the message is closed.

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: textbox exit event by clicking another control

    Try this to capture the entrance in to button control so you can re-trigger the click event

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Textbox exit event prevents to exit userform
    By smjjvh in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-21-2014, 06:08 AM
  2. Add Cancel argument to Textbox Exit event
    By Idahoanne in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-08-2014, 12:13 AM
  3. [SOLVED] Userform multipage control - exit event not firing or event order
    By jane serky in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-14-2013, 10:23 AM
  4. [SOLVED] Problems with Exit event for Textbox
    By tfurnivall in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-11-2013, 11:03 AM
  5. Textbox Exit Event Cant not be trigger
    By stewegg in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-26-2012, 01:26 PM
  6. Userform textbox event that fires after I exit the textbox
    By jerseyguy1996 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 02-04-2010, 08:08 AM
  7. Exit Event with a single textbox control
    By ChazE911@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-08-2006, 09:55 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1