Results 1 to 6 of 6

Thread: [RESOLVED] Multiple ComboBoxes Change Event? And ComboBox(variable)

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2005
    Location
    Chicago
    Posts
    9

    Resolved [RESOLVED] Multiple ComboBoxes Change Event? And ComboBox(variable)

    I am working with 27 ComboBoxes on a UserForm that all work to form a model code. I have two questions...

    First Question:
    How do I make a private sub that is a change event if ANY of the combo boxes change?

    Instead of:
    Private Sub ComboBox1_Change()
    Private Sub ComboBox2_Change()
    Private Sub ComboBox3_Change()
    ...
    ...
    ...
    Private Sub ComboBox27_Change()

    Use This:
    Private Sub Any ComboBox_Change() - how do I do this?

    Second question:
    How do I refer to a variable combo box?

    If n = 5, then refer to ComboBox5

    Thanks for any help you can offer...

    Rookie

  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Multiple ComboBoxes Change Event? And ComboBox(variable)

    You should create a control array. Then you can access your comboboxes like this :

    VB Code:
    1. Private Sub ComboBox_Change(Index As Integer)
    2.  
    3. ComboBox(2).ListIndex = 7 '<--- number in the parenthesis shows which combobox you are accessing


    Has someone helped you? Then you can Rate their helpful post.

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2005
    Location
    Chicago
    Posts
    9

    Re: Multiple ComboBoxes Change Event? And ComboBox(variable)

    Manavo,

    Thank you, but I'm still lost. If I'm a first grader trying to understand Calculus, just let me know and I'll drop it, but I don't know how to establish an array. Is that a simple declaration statement? I can't find anything in the archives or in VBA help.

    Rookie

  4. #4
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Multiple ComboBoxes Change Event? And ComboBox(variable)

    It seems that this can't be done in VBA, I was thinking that it could since it can be done in VB6 but it seems it can't


    Has someone helped you? Then you can Rate their helpful post.

  5. #5
    Hyperactive Member nagasrikanth's Avatar
    Join Date
    Nov 2004
    Location
    India,Hyderabad.
    Posts
    420

    Lightbulb Re: Multiple ComboBoxes Change Event? And ComboBox(variable)

    Try this....it will works in ACCESS...

    VB Code:
    1. Me("combo" & CStr(i)).value


    All the best

    Anu..
    The Difference between a Successful person and others is not a Lack of Knowledge,
    But rather a Lack of WILL

  6. #6

    Thread Starter
    New Member
    Join Date
    Aug 2005
    Location
    Chicago
    Posts
    9

    Re: Multiple ComboBoxes Change Event? And ComboBox(variable)

    Anu,

    Yes, the below works. Thanks...

    Rookie

    i = 7
    MsgBox Me("ComboBox" & CStr(i)).Value

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width