+ Reply to Thread
Results 1 to 12 of 12

Userform textbox event that fires after I exit the textbox

  1. #1
    Forum Contributor
    Join Date
    03-13-2009
    Location
    New Jersey
    MS-Off Ver
    Excel 2007
    Posts
    136

    Userform textbox event that fires after I exit the textbox

    I need a userform textbox event that fires after I tab or click out of the textbox. Going by the list of options:Beforedragover, BeforeDroporPaste, Change, DblClick, DropButtonClick, Error, Keydown, Keypress, keyup, mousedown, mousemove, mouseup.

    I can't figure out which one will do what I want. The change event happens instantaneously which doesn't work. I need to fire off the event when my focus leaves the textbox.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,971

    Re: Userform textbox event that fires after I exit the textbox

    The Exit event?
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Contributor
    Join Date
    03-13-2009
    Location
    New Jersey
    MS-Off Ver
    Excel 2007
    Posts
    136

    Re: Userform textbox event that fires after I exit the textbox

    That wasn't on my list of choices but I will give it a try.

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,971

    Re: Userform textbox event that fires after I exit the textbox

    It's inherited from the base Control class so it doesn't appear as a Textbox event in the Object Browser for instance.

  5. #5
    Forum Contributor
    Join Date
    03-13-2009
    Location
    New Jersey
    MS-Off Ver
    Excel 2007
    Posts
    136

    Re: Userform textbox event that fires after I exit the textbox

    Is there some additional code that I will need in my class module to make it work? This is what I have so far:

    Please Login or Register  to view this content.
    It doesn't seem to be firing based on the code that I have there currently.

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,971

    Re: Userform textbox event that fires after I exit the textbox

    Ah, didn't realise you were using it WithEvents. It can't be used there, I'm afraid. (and nor can you use a Withevents Control variable).

  7. #7
    Forum Contributor
    Join Date
    03-13-2009
    Location
    New Jersey
    MS-Off Ver
    Excel 2007
    Posts
    136

    Re: Userform textbox event that fires after I exit the textbox

    So I am out of luck? These are controls that are created at runtime so my understanding was that you had to create a class module and write all of the event procedures there. All of my other controls that are created at runtime are working. Is there a different event that is available that might be able to do the same thing?

    P.S. The guidance you gave me on the issue with looping commandbutton events was spot on. It was because I was associating the command button with each instance of my class.

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,971

    Re: Userform textbox event that fires after I exit the textbox

    Let's go back to the beginning for a moment then - why are you creating the textboxes at runtime?

  9. #9
    Forum Contributor
    Join Date
    03-13-2009
    Location
    New Jersey
    MS-Off Ver
    Excel 2007
    Posts
    136

    Re: Userform textbox event that fires after I exit the textbox

    Quote Originally Posted by romperstomper View Post
    Let's go back to the beginning for a moment then - why are you creating the textboxes at runtime?
    Because I won't know ahead of time how many lines will need to be created by the user. They click on a commandbutton to add a new line. Attached is my workbook with some working code. Right now I am using the mouseover event to format the text in the text box. It works but I see it as a sloppy compromise.
    Attached Files Attached Files

  10. #10
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,971

    Re: Userform textbox event that fires after I exit the textbox

    Why not have three textboxes and a combobox on the form (added at design time) then add the data to a list box and clear the textboxes/combobox ready for the next record? You could then add controls to reorder/add/delete items in the listbox.

  11. #11
    Forum Contributor
    Join Date
    03-13-2009
    Location
    New Jersey
    MS-Off Ver
    Excel 2007
    Posts
    136

    Re: Userform textbox event that fires after I exit the textbox

    That is actually a really good idea. I will have to explore that. It may make it easier for individuals that have multiple portfolios that need to be consolidated into one total return.

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

    Re: Userform textbox event that fires after I exit the textbox

    looks like 3rd times the charm

    Using the listbox and single set of entry textboxes removes all the hassle of insertion/deletion of records, adding controls on the fly, capturing events, resizing of userform
    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)

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