Runtime 3075 (syntax error) missing operator

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bennett72
    New Member
    • Mar 2012
    • 2

    #1

    Runtime 3075 (syntax error) missing operator

    Hello - I'm getting a run time error 3075 (missing operator) in my query expression and cannot seem to determine why. I cut a snippet of code (see below) and ran the statement in a sql query view and it returned the values back as perfectly. However, I get the qdf.SQL = strSQL debug for this statement when I try an run it in a form:

    'Set the final Query Statemnt
    strSQL = "SELECT * FROM wktbl_YTDTransa ctions Where " & strQuery & ";"

    I'm lost. Any ideas as to what could be missing? Any responses are greatly appreciated
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    That depends on what's in strQuery.

    Comment

    • Bennett72
      New Member
      • Mar 2012
      • 2

      #3
      Thanks for the reply. Here is an excerpt of the code along with the statement with strQuery:

      Code:
      strQuery = strQuery & "wktbl_YTDTransactions!" & tCtrl.ControlSource & " IN(" & strCriteria & ")"
                      strQuery = strQuery & " AND "
                  End If
                  
              End If
                      
            Next tCtrl
            
          'Trim the last AND off the strQuery or it will throw an error
           strQuery = Left(strQuery, Len(strQuery) - 5)
           
           'Set the final Query Statemnt
           strSQL = "SELECT * FROM wktbl_YTDTransactions Where " & strQuery & ";"
                     
           qdf.SQL = strSQL
           
           DoCmd.OpenQuery "sysqry_YTDTransactions Query"
      Last edited by Rabbit; Mar 12 '12, 07:43 PM. Reason: Please use code tags when posting code.

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Please use code tags.

        It now depends on what's in strCriteria. Why do you keep leaving out information that we need?

        Also, what is "wktbl_YTDTrans actions!"? If it's a table, you can't use the exclamation mark. If it's a form control, you forgot the Form! in front.

        Comment

        Working...