Where Clause with Multiple Criteria

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Aftab Ahmad
    New Member
    • Jan 2015
    • 49

    Where Clause with Multiple Criteria

    Well! I have a list called List537 and I want to show two number of columns in it, after entering my value (number) in an unbound text box. I know how to get data source in the list with a single WHERE clause however, I want to use multiple criteria to get accurate results. I have a table called "Objectives " where two columns are exists i.e., Number and Question. I want to show them in a List537 wherein quantity of bounded columns are two with the size of 1";2". I have write the code below but facing "syntax error".

    Code:
    Me.List537.RowSource = "SELECT [Objectives].[Number],[Objectives].[Question]FROM " & _
            " Objectives WHERE [SubjectID]= & Me.SubjectID And [ClassID] = & Me.ClassID" & _
            " Order By Number"
    Please anybody help. Thanks in advance.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32661

    #2
    Hi Aftab.

    I wish I had a pound for every question where someone asks why 'X' doesn't work and they don't even include 'X' in the question - just an isolated selection of code that produces whatever 'X' is. We can never know what 'X' is because there are various references to variables of one type or another we have no information about.

    So, I get your frustration when you are struggling with something, but please at least try to get the basics of the question down.

    In this case it's clear that the last line (ORDER BY) can't work as you've used a reserved word (Number) without qualifying it in any way so it has no way of knowing you're trying to reference a Field in your Table, so obviously that will certainly fail. There may be further problems we could help with if/when you post the actual value you're trying to assign to Me.List537.RowS ource, but they'll have to wait till we have such information.

    Comment

    • Aftab Ahmad
      New Member
      • Jan 2015
      • 49

      #3
      OMG! Thanks NeoPa. I completely understood. Now, its working fine. Thanks again

      Comment

      Working...