Results 1 to 4 of 4
  1. #1
    Goodge12 is offline Novice
    Windows XP Access 97
    Join Date
    Sep 2008
    Posts
    25

    Cascading Combo 2 Boxes - Need to Group second wave

    Hi All-

    I have a table (tblExample) set up that is something like this...

    Main Secondary Tertiary
    A 1 a
    A 1 b
    A 1 c
    A 2 a
    A 2 b
    A 2 c
    B 3 a


    B 3 b
    B 3 c



    I set up a three combo boxes on a form. The combo boxes are based on that table. I'll call them cboMain, cboSecondary, cboTertiary

    I was able to make them cascade (so in other words, if the user chooses "A" for the cboMain, they have choices 1 and 2) by using the following:

    Code:
    Private Sub cboMain_AfterUpdate()
      
      Dim strSource     As String
      
        strSource = "SELECT cboSecondary " & _
                  "FROM tblExample" & _
                  "WHERE Main = '" & Me.cboMain & "' ORDER BY Secondary"
        Me.cboSecondary.RowSource = strSource
        Me.cboSecondary = vbNullString
            
    End Sub
    The issue I'm having is that instead of just returning choices 1 and 2 for cboSecondary, I get choices 1,1,1,2,2,2

    Is there a line of code or something I can plug in where it will force a "Group By" of the results?

    Any help would be appreciated. Thank you!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Either


    strSource = "SELECT DISTINCT cboSecondary " & _

    or

    "WHERE Main = '" & Me.cboMain & "' GROUP BY Secondary ORDER BY Secondary"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Goodge12 is offline Novice
    Windows XP Access 97
    Join Date
    Sep 2008
    Posts
    25
    "WHERE Main = '" & Me.cboMain & "' GROUP BY Secondary ORDER BY Secondary" worked perfectly.

    I was trying it as:
    "WHERE Main = '" & Me.cboMain & "' GROUP BY Secondary " & "'ORDER BY Secondary "

    Thank you, Paul- much appreciated!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help! You could have done it that way, though the extra concatenation would be a slight performance hit. You had an extra apostrophe in there before ORDER which would have made it barf.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Cascading combo boxes
    By Jackie in forum Access
    Replies: 5
    Last Post: 07-26-2013, 09:07 AM
  2. Replies: 5
    Last Post: 11-21-2011, 09:59 PM
  3. Sum of Cascading Combo Boxes
    By alonewolf23 in forum Forms
    Replies: 2
    Last Post: 11-20-2011, 02:10 PM
  4. Cascading combo boxes
    By combine21 in forum Forms
    Replies: 3
    Last Post: 12-02-2010, 12:57 PM
  5. Cascading Combo Boxes
    By desireemm1 in forum Programming
    Replies: 1
    Last Post: 10-05-2009, 06:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums