+ Reply to Thread
Results 1 to 4 of 4

Exit event for Dynamically created textbox in a userform

  1. #1
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Exit event for Dynamically created textbox in a userform

    Good morning fellow coders. I have a challenge that I can't seem to figure out. I have looked online quite a bit, but still can't find a good solution to this problem.

    I have a userform, where the number of rows is variable depending on the user's needs. Some of the textboxes I create, I would like to trigger an Exit event. Using a class module, I am able to use certain events, such as Change, DblClick, KeyPress and a few others, but Exit (or even AfterUpdate) are not available that way.

    Does anyone know of a way to assign an Exit event to dynamic textboxes?

    Arkadi.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,645

    Re: Exit event for Dynamically created textbox in a userform

    Hi Arkadi,

    The approach taken in the attached workbook might get you moving in the right direction.

    The UserForm displayed when you click on the "Show Form" button contains five TextBoxes, three of which have green backgrounds. These TextBoxes have custom "LostFocus" events which will probably be adequate substitutes for the "Exit" events which you're trying to implement.

    In the following routine, the highlighted values can be substituted with the Names of the TextBoxes which you create dynamically:

    Please Login or Register  to view this content.

    Hope this helps - please let me know how you get on.

    Regards,

    Greg M
    Attached Files Attached Files

  3. #3
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Exit event for Dynamically created textbox in a userform

    Thanks Greg
    I had found a really good post, and just couldn't get it to work... but that's probably due to being dumb... the userform may have controls, but since they are on a frame, they were not triggering the custom exit event I was working on. I just finished fixing that, and then saw your post, which is also a really good solution!

    FWIW in future searches, here is my solution:

    In a class module named clsWatchEvents: (if not working with a frame just remove "Frame1." from the code:

    ' Author: Jaafar Tribak http://www.mrexcel.com/forum/showthread.php?t=519492
    Please Login or Register  to view this content.
    Then in the userform code itself (I left in the loop creating dynamic textboxes):

    'using event code from Jaafar Tribak http://www.mrexcel.com/forum/showthread.php?t=519492
    Please Login or Register  to view this content.

  4. #4
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,645

    Re: Exit event for Dynamically created textbox in a userform

    Hi again Arkadi,

    Many thanks for your very prompt feedback and also for the Reputation increase - much appreciated!

    If you look in the code of the "C24_WatchFormControls" Class Module I posted, you'll find that it contains an acknowledgement referencing the same webpage as you do - good ol' Jafaar Tribak, eh?

    Best regards,

    Greg M

+ 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. [SOLVED] Userform - Cannot transfer value of textbox to range when created dynamically
    By Chrispelletier in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-15-2016, 10:15 AM
  2. 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
  3. Texbox exit event prevents userform exit
    By smjjvh in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-21-2014, 05:47 AM
  4. [SOLVED] Adding change event to dynamically created option buttons on userform
    By Arkadi in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-21-2014, 11:38 AM
  5. Stop exit event of textbox firing when click a command button to close a userform
    By chrisjames25 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-18-2013, 09:27 AM
  6. Userform Textbox Exit Event to Run Application
    By baisty182 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-29-2010, 12:30 PM
  7. 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

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