+ Reply to Thread
Results 1 to 5 of 5

Change event for controls added

  1. #1
    Registered User
    Join Date
    09-22-2011
    Location
    san diego
    MS-Off Ver
    Excel 2013
    Posts
    76

    Change event for controls added

    Hello,

    I have been building dynamic entry forms via method shown below.

    Please Login or Register  to view this content.
    I am curious if there is a way to add a change event to a newly added control within a running userform? I'd like to be able to have the user enter info on this newly added "temp" textbox that would then do a search afterupdate.

    Thanks!

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

    Re: Change event for controls added

    You can use a class object that has a control object withevents. Note not all events are available.

    useform code
    Please Login or Register  to view this content.
    class CCtlEvt code
    Please Login or Register  to view this content.
    The userform has a button that will add a control when clicked.
    Changed text is displayed in immediate window and the userforms caption.


    It's can sometimes simpler to add controls at design time and then make them visible and enabled at run time.
    Attached Files Attached Files
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    09-22-2011
    Location
    san diego
    MS-Off Ver
    Excel 2013
    Posts
    76

    Re: Change event for controls added

    Awesome thank you! Something new to learn

    Definitely agree, and have historically used visible true/false for this, but for this project, the control qty and & dynamics makes this path more viable.

    The reality is I'd love to embed a spreadsheet but it appears that reference library has been obsolete for a while.

    Thanks again!

  4. #4
    Registered User
    Join Date
    09-22-2011
    Location
    san diego
    MS-Off Ver
    Excel 2013
    Posts
    76

    Re: Change event for controls added

    One follow up now that I'm applying this great solution. In my case, I'll be making textbox groups with one primary box that I want the change event on...click the command button and a group of 5 boxes appear, with the first of that column being the box I want a change event.

    Please Login or Register  to view this content.
    Above I added a name thinking maybe I can set multiple boxes to the same mCtlEvt? Clearly not working but maybe there is a way that will? The idea is the user may make anywhere from 1 to 20+ groups of 5 so I could make enough discretely named class modules, but would prefer a more elegant solution.

    Thinking maybe the class module can see if an object ends in "_1" then the change event will be triggered?

    Thanks!

  5. #5
    Registered User
    Join Date
    09-22-2011
    Location
    san diego
    MS-Off Ver
    Excel 2013
    Posts
    76

    Re: Change event for controls added

    For more clarity...currently it's only working for the last "Set" vs. ideal where any of the 3 "event" textboxes would change the parent name on change

    Screenshot 2023-02-01 152418.jpg

+ 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. Fix change event code to add todays date when data is added to multiple cells in column
    By Nitefox in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 3
    Last Post: 12-21-2013, 06:40 PM
  2. [SOLVED] how can I trap the change event (Tab Press key) of these controls
    By Padam in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-11-2006, 04:45 AM
  3. how can I trap the change event (Tab Press key) of these controls
    By Padam in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-11-2006, 04:45 AM
  4. [SOLVED] how can I trap the change event (Tab Press key) of these controls
    By Padam in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-10-2006, 11:05 AM
  5. [SOLVED] add event to controls added in runtime
    By Brotha lee in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-21-2005, 06:06 AM
  6. [SOLVED] Event procedures for controls added with CreateEventProc
    By John Austin in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-24-2005, 12:06 PM
  7. [SOLVED] Event procedures for controls added with CreateEventProc
    By John Austin in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-12-2005, 06:06 PM
  8. Event procedures for controls added with Controls.Add
    By John Austin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-09-2005, 01:06 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