Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2005

    Unanswered: Run code on each item in combo box

    Hi again,

    Can someone tell me the best method to run a line of code on each item in a combo box.


    When I click on something in the combo box it will assign a value to a textbox, but that value can change depending on what is clicked in the combo box.

    I tried using a Select Case statement and use Case 1, 2...etc for each item in the combo box, but it seems I can't use that with the combo box.

    So what's the best method?


  2. #2
    Join Date
    Mar 2003
    The Bottom of The Barrel
    Provided Answers: 1
    Dim i As Integer
    For i = 0 To myCombo.ListCount - 1
        'do some stuff like
        MsgBox myCombo.Column(0, i)
    Next i
    forgot, you can use myCombo.ListIndex to get ahold of the currently selected item. Remember, it's zero-based...
    Last edited by Teddy; 09-26-06 at 13:16.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Sep 2005
    Thanks Teddy,

    I did managed to use a Select Case statement in the end.
    It seems if you just specify the combo box control name it doesn't work, but if you use the ListIndex property it does pick it up.
    And as you said because it is zero-based the first case wil be 0, instead of 1.

Posting Permissions

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