Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2004
    Posts
    13

    Unanswered: List Boxes That Change Based On Other Values

    Hello everyone,

    I am currently trying to make a set of Drop Down Lists where the values in the second list CHANGE when you make a selection in the first list.

    I dont know how difficult this may be, but I am willing to give it a shot. I am having a hard time finding out what this is called in the help section... so im not really making any headway.

    heres the idea...

    If I select option 1 in the first drop down box, I should only be allowed to choose A, B, and C in the second.
    If I select option 2 - D, E, and F
    and so on and so on...

    Thanks for any help in advance!

  2. #2
    Join Date
    Nov 2004
    Posts
    13
    I should also mention that I noticed a spot below that talks about a similar idea, but I am not CODE savy at all... so some of it is cryptic...


  3. #3
    Join Date
    Feb 2005
    Location
    The Hague, Netherlands
    Posts
    95
    Quote Originally Posted by voodoo_ca
    I should also mention that I noticed a spot below that talks about a similar idea, but I am not CODE savy at all... so some of it is cryptic...

    Yep I had the exact same problem. Solution I used is to set the rowsource of the second dropdown-list accroding to the value selected in the first.

    I have to go now, but check out the earlier topic by me and if you dont succeed I'll post my code here tomorrow. ;-)

  4. #4
    Join Date
    Nov 2004
    Posts
    13
    Thanks, ill take a look and see what I can figure out!

  5. #5
    Join Date
    Jun 2004
    Posts
    92
    Here is a sample of what you are looking for:

    You would put this code in the onchange event for the first combo box. It assumes that you are using a value list for the source.

    Code:
    Select Case cmbfirst.Value
        Case "1"
            cmbsecond.RowSource = "'A';'B';'C'"
        Case "2"
            cmbsecond.RowSource = "'D';'E';'F'"
        Case Else
            cmbsecond.RowSource = ""
    End Select
    That should get you headed in the right direction.

  6. #6
    Join Date
    Feb 2005
    Location
    The Hague, Netherlands
    Posts
    95
    Quote Originally Posted by sionus
    Here is a sample of what you are looking for:

    You would put this code in the onchange event for the first combo box. It assumes that you are using a value list for the source.

    Code:
    Select Case cmbfirst.Value
        Case "1"
            cmbsecond.RowSource = "'A';'B';'C'"
        Case "2"
            cmbsecond.RowSource = "'D';'E';'F'"
        Case Else
            cmbsecond.RowSource = ""
    End Select
    That should get you headed in the right direction.
    Yep ^^
    And when you want both comboboxes based on values from Tables, just put an SQL-statement as Rowsource (which can include a variable here).

    So:
    var = cmbfirst.value

    cmbsecond.Rowsource = "SELECT data FROM table WHERE condition = " & var

    good luck!

Posting Permissions

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