+ Reply to Thread
Results 1 to 4 of 4

Populating a Textbox in a Userform

  1. #1
    Registered User
    Join Date
    06-04-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    54

    Populating a Textbox in a Userform

    2007 Excel

    I have created a userform that has a series of textbox's. When I activate the userform with the userform.show property I will either populate the textboxes with template data or, if data has been saved previously it will populate the textbox's with the saved data.

    I have set up code to run if the user then changes any of the textbox's - I call a sub with "afterupdate" code written into each textbox.

    Here is the problem - When I initially show the userform and populate the textbox's with template data or saved data it thinks it needs to run the "afterupdate" code at that time - I don't want it to. Is there a way to populate the textbox's during the Userform Activate sub without it running the code written into the text box?

    I hope that this is no too confusing. Thanks for your help.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Populating a Textbox in a Userform

    Jeff

    What code are you using to populate the textboxes?

    Also, why the AfterUpdates for each textbox? Are you validating something?
    If posting code please use code tags, see here.

  3. #3
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Populating a Textbox in a Userform

    hi

    I declare a change flag and use that to control updates. The Changeflag must be public so declare it at the top of your module.

    Example.

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    06-04-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    54

    Re: Populating a Textbox in a Userform

    Norie -

    I use code like this:

    Please Login or Register  to view this content.
    WHen I activate the userform I run this code to populate the textbox's - I dont want it to run the code attributed to the textbox unless the user makes a change.

    mehmetcik -

    I will give it a try - that should do the trick.

+ 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