Results 1 to 4 of 4
  1. #1
    David30184 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2014
    Posts
    4

    Combo's limited by other combo value

    I have three tables (SkillList), (SubSkillList), and (SubSkillList2) to populate 3 combo boxes - cboSkillList, cboSubSkillList and cbosubSkillList2. I want each limited by the proceeding. The first works fine (SubSkillList) IS limited by (SkillList). I'm unable to get the third to return a value. It's returning...

    Syntax error (missing operator) in query expression '[SubSkillID] = Class A'

    where "Class A" is the text of the selected value in the table (SubSkillList) - can't determine where it's failing (?) Any guidance is appreciated!!

    Code as follows:

    Private Sub cboSkillList_AfterUpdate()


    With Me![cboSubSkillList]
    If IsNull(Me!cboSkillList) Then
    .RowSource = ""
    Else
    .RowSource = "SELECT [SubSkill] " & _
    "FROM SubSkillList " & _
    "WHERE [SkillID]=" & Me!cboSkillList
    End If
    Call .Requery
    End With
    End Sub



    Private Sub cbosubSkillList_AfterUpdate()

    With Me![cboSubSkillList2]
    If IsNull(Me!cboSubSkillList) Then
    .RowSource = ""
    Else
    .RowSource = "SELECT [SubSkill2] " & _
    "FROM SubSkillList2 " & _
    "WHERE [subSkillID]=" & Me!cboSubSkillList
    End If
    Call .Requery
    End With


    End Sub

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    You've gone the long way on this. Each combo should connect to a query.

    SkillList.rowsource = qsList1

    cbosubSkillList.rowsource = "qsList2" where the query qsList2: should reference the combo : SkillList as criteria

    same with the 3rd combo
    THEN the only code needed is
    Code:
    cbosubSkillList_AfterUpdate()
       cbosubSkillList.requery
    end sub
    Whenever you change a combo value, run a REQUERY on the other combos. (not big blocks of code)

  3. #3
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    If the combo box values are text and not numeric valies, you need quotation marks around the values:

    .RowSource = "SELECT [SubSkill2] " & _
    "FROM SubSkillList2 " & _
    "WHERE [subSkillID]='" & Me!cboSubSkillList & "'"

    and it appears the values in Me!cboSubSkillList are text values.

    HTH

    John

  4. #4
    David30184 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2014
    Posts
    4
    I'll try that out - Thanks!!

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

Similar Threads

  1. Replies: 3
    Last Post: 07-03-2013, 10:38 AM
  2. Replies: 1
    Last Post: 10-30-2012, 10:29 AM
  3. Replies: 2
    Last Post: 08-16-2012, 10:02 PM
  4. Replies: 1
    Last Post: 03-27-2012, 07:10 AM
  5. Replies: 4
    Last Post: 08-16-2011, 05:54 PM

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