+ Reply to Thread
Results 1 to 10 of 10

Using a class module for several userforms, identify which userform is active

  1. #1
    Registered User
    Join Date
    11-01-2022
    Location
    venezuela
    MS-Off Ver
    365
    Posts
    10

    Using a class module for several userforms, identify which userform is active

    Greetings gentlemen, I found this code, and the truth is that it works very well, it is a class module that creates a matrix for different controls (textboxes, combobox, listbox, etc.) it is really very versatile since you can assign different events For each control, I would like to use it with several userforms, for this I would need to verify which userform is loaded or active when the event is activated, I imagine it is with a function, but this must be at the class module level, thanks for any ideas you can contribute. ..

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,220

    Re: Using a class module for several userforms, identify which userform is active

    Try making the following changes.
    In the form module, replace the line:
    Please Login or Register  to view this content.
    to:
    Please Login or Register  to view this content.
    In the class module add:
    Please Login or Register  to view this content.
    and change the procedure to:
    Please Login or Register  to view this content.
    Artik

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,779

    Re: Using a class module for several userforms, identify which userform is active

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not told us about this. You are required to do so.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important: https://excelguru.ca/a-message-to-forum-cross-posters/

    (Note: this requirement is not optional. As you are new here, I shall do it for you this time: http://www.vbaexpress.com/forum/show...form-is-active)
    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.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  4. #4
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,220

    Re: Using a class module for several userforms, identify which userform is active

    Yet another way.
    In the form module, the UserForm_Activate procedure remains in your version. Although for testing you can the following version:
    Please Login or Register  to view this content.
    In the class module add:
    Please Login or Register  to view this content.
    and change the procedures to:
    Please Login or Register  to view this content.
    I don't know if it follows the rules of the art, but it should work.

    Artik

  5. #5
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Using a class module for several userforms, identify which userform is active

    Keep it simple.
    I'd use:

    In each userform:
    Please Login or Register  to view this content.
    In the class module
    Please Login or Register  to view this content.
    Attached Files Attached Files



  6. #6
    Registered User
    Join Date
    11-01-2022
    Location
    venezuela
    MS-Off Ver
    365
    Posts
    10

    Re: Using a class module for several userforms, identify which userform is active

    Greetings, a thousand apologies, it was not my intention, however, I reported in the publication and when trying to publish a window was displayed with a message that said "sharing images and links is prohibited" so I deleted it, I will be careful in the future, thanks and success ...

  7. #7
    Registered User
    Join Date
    11-01-2022
    Location
    venezuela
    MS-Off Ver
    365
    Posts
    10

    Re: Using a class module for several userforms, identify which userform is active

    Artik thanks for the suggestion, below I leave the code with the changes that you indicated to me, maybe you can make some corrections, I still haven't achieved the objectives, I will be attentive to your suggestions

    Please Login or Register  to view this content.
    Last edited by kapela; 01-22-2023 at 08:21 PM.

  8. #8
    Registered User
    Join Date
    11-01-2022
    Location
    venezuela
    MS-Off Ver
    365
    Posts
    10

    Re: Using a class module for several userforms, identify which userform is active

    Snb I have been reviewing your code and it is simply impressive, it creates a matrix and excludes the userforms that are not activated, I will replace it with the current one, in that case, if you want to enter an afterupdate event, it would only be enough to make the corresponding declaration?...

  9. #9
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Using a class module for several userforms, identify which userform is active

    You don't want to create an 'afterupdate' event.
    If you need that, it means you want to check whether the user has made valid inputs.
    You should not allow users to enter unvalid values.
    Populate a combobox/listbox with only valid values; that's how you should do this.

  10. #10
    Registered User
    Join Date
    11-01-2022
    Location
    venezuela
    MS-Off Ver
    365
    Posts
    10

    Re: Using a class module for several userforms, identify which userform is active

    Ok I understand, you will see in one of the events with Optionbuttom I need to calculate some percentages dynamically the Afterupdate event works well for me

    Please Login or Register  to view this content.
    It works dynamically and fluidly, what I try to do is that if you active the OptionButton2 this same textbox has a format with the change event to work with currency format, I am sure that it can be achieved with macros if you have knowledge about the manipulation of Events would thank you for reading about it but applies to Access 2013 with the Event Method

+ 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] Class module for userform textboxes
    By Knoet in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-04-2020, 06:59 PM
  2. Place code in userform, module or class module
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-16-2017, 07:04 AM
  3. Add Property to UserForm via class module - please help
    By jaryszek in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-07-2016, 09:35 AM
  4. [SOLVED] Userform ComboBox Class Module not working
    By rodgersmg in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-24-2016, 03:23 AM
  5. [SOLVED] Userform & Dynamic Controls & Class Module
    By sarndt01 in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 09-18-2014, 01:53 PM
  6. [SOLVED] Identify and make active specific VBProject for module import
    By AlvaroSiza in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-11-2013, 10:51 AM
  7. Replies: 1
    Last Post: 10-12-2012, 04:36 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