+ Reply to Thread
Results 1 to 5 of 5

Class Module & GotFocus with ComboBoxes

  1. #1
    Registered User
    Join Date
    12-01-2007
    Posts
    42

    Class Module & GotFocus with ComboBoxes

    Hello,

    I would like to create a class module to simplify my procedure. These are ComboBoxes that depend on the GotFocus event.
    I started, somehow, to deal with the problem, but it didn't work.
    How to do it ?
    Attached Files Attached Files

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

    Re: Class Module & GotFocus with ComboBoxes

    Hi there,

    I haven't read your code in detail, but it seems that you're trying to use the GotFocus event in a Class module which contains a ComboBox object declared WithEvents.

    Unfortunately (as far as I am aware) the GotFocus event is not exposed in such a situation. When you place the cursor inside your "CBL_Click" routine you can see the list of available events in the dropdown list at the top of the VBA Editor window (GotFocus is not included).

    I had a similar requirement some years ago and I found that an excellent solution had been developed by Jaafar Tribak; it can be found using the following link:



    Hope this helps you - it certainly helped me!

    Regards,

    Greg M

  3. #3
    Registered User
    Join Date
    12-01-2007
    Posts
    42

    Re: Class Module & GotFocus with ComboBoxes

    Hello Greg M,

    I looked a bit on other forums, actually it does not seem to be possible.
    I will try to go through Click instead of GotFocus. But it is not won ...
    Last edited by Magic_Doctor; 09-28-2021 at 11:22 PM.

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

    Re: Class Module & GotFocus with ComboBoxes

    Hi again,


    I looked a bit on other forums, actually it does not seem to be possible.


    But I think that it very definitely IS possible!

    Take a look at the attached workbook and see if it gets you moving in the right direction. Select/tab through the various controls on the UserForm and see how the ComboBoxes respond when they receive or lose the focus.

    The VBA CodeModule for the UserForm contains the following code:

    Please Login or Register  to view this content.
    And a Class Module called "C21_WatchFormControls" contains the following code:

    Please Login or Register  to view this content.

    As I mentioned in my original post, I'm happy to acknowledge that the idea behind the above code came from Jaafar Tribak.

    By the way, I just love the lists of "ingredients" in your ComboBox dropdown lists.

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

    Regards,

    Greg M
    Attached Files Attached Files

  5. #5
    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
    81,247

    Re: Class Module & GotFocus with ComboBoxes

    Administrative Note:

    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 provided the required cross-post link(s) here.

    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.

    (Note: this requirement is not optional. No help to be offered until the link is provided.)
    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.

+ 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 Events : How to refering to individual class members
    By kev_ in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-29-2020, 06:27 AM
  2. Class Module to design a class based on an autoshape (arrow)
    By BluesEnd in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-18-2017, 07:23 AM
  3. 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
  4. [SOLVED] ComboBox class .AddItem filled in class module
    By Jacques Grobler in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-03-2012, 05:48 AM
  5. Populating comboboxes and ranges through a class module
    By Mats Samson in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-08-2011, 01:14 PM
  6. Replies: 1
    Last Post: 08-30-2011, 02:23 AM
  7. comboboxes, userforms and class modules
    By natanz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-29-2005, 11:10 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