Results 1 to 4 of 4
  1. #1
    KLynch0803 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2009
    Posts
    37

    Post Syntax error (comma) in query expression

    I keep getting this error can anyone help me find the error. I have been searching for two days. Any help is greatly appreciated.



    Here is what I have. I have a table residing on a server which has all read, write, change access. It is named "tbl_Service_Providers"

    I'm reading three fields in the table "Approved", "Services_Provided" (Could contain multiple Values in it seperated by comma's in it (MEMO FIELD)), "AreaCovered" (Could contain multiple values seperated by comma's in it (MEMO FIELD)). Based on the selections on the asp page it should pull all matching records. I'm using the "%" as my wildcard for multiple value fields.


    <!----- Error ----->


    Microsoft JET Database Engineerror '80040e14'
    Syntax error (comma) in query expression 'Approved, Services_Provided, CoverageArea LIKE 'True' 'Air Conditioning & Cooling' '27611''. /servicebidpro/DOUG EmployeeReports (Design).asp, line 851

    <!----- END ERROR ----->


    Snippet of area with actual error "ACTUAL WRITTEN CODE"
    ** I didnt want to provide complete code to save server space in forum as its over 1000 lines long but if you need I can...
    Code:
     
    if DetectedButton = "Get Provider Based on Approval, Service, Coverage" then
      'Prep the database to be accessed
      set conn=Server.CreateObject("ADODB.Connection")
      conn.Provider="Microsoft.Jet.OLEDB.4.0"
      conn.Open(Server.Mappath("/Mypath to db.mdb"))
      set rs = Server.CreateObject("ADODB.recordset")
     
      'Format the Query to use against the database
        sql="SELECT Service_Company_Name, Contact_Name FROM tbl_Service_Providers WHERE "
      sql = sql & "Approved, " & "Services_Provided, " & "CoverageArea " & "LIKE "
      sql = sql & "'" & Request.Form("ApprovedorNot") & "' "
      sql = sql & "'" & Request.Form("ServiceType") & "' "
      sql = sql & "'" & Request.Form("CoverageArea") & "'"
      Response.Write(sql)
      rs.Open sql, conn
    Here is the code that is sent after you make your selections and hit the appropriate button to get records.

    Code:
     
    SELECT Service_Company_Name, Contact_Name FROM tbl_Service_Providers WHERE Approved, Services_Provided, CoverageArea LIKE 'True' 'Air Conditioning & Cooling' '27611'
    Last edited by KLynch0803; 01-17-2010 at 09:57 AM. Reason: Missed a piece of code that is sent after selection

  2. #2
    KLynch0803 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2009
    Posts
    37
    Can knowone find this error? A friend said something about placing a shoe? I guess he was talking about <% %> but that already exists.. hmmm

  3. #3
    Rainlover's Avatar
    Rainlover is offline Expert
    Windows XP Access 2003
    Join Date
    Nov 2009
    Location
    Queensland Australia
    Posts
    691
    Where Approved what???

    Approved must equal something.

    Try using the query builder to write this then put into you VBA as a string.

    But get it to work as a query first.

  4. #4
    Rainlover's Avatar
    Rainlover is offline Expert
    Windows XP Access 2003
    Join Date
    Nov 2009
    Location
    Queensland Australia
    Posts
    691
    Also SQL is a reserved word.

    Try strSQL instead.

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

Similar Threads

  1. Sql Syntax Query
    By Matthieu in forum Queries
    Replies: 4
    Last Post: 12-30-2009, 09:41 AM
  2. Replies: 1
    Last Post: 10-07-2009, 07:36 AM
  3. Replies: 1
    Last Post: 07-31-2009, 03:57 AM
  4. sql syntax error
    By SMAlvarez in forum Access
    Replies: 1
    Last Post: 03-12-2009, 09:43 PM
  5. Syntax Error In Insert Into Statement
    By frankvfox in forum Queries
    Replies: 1
    Last Post: 09-09-2008, 12:35 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