Results 1 to 4 of 4
  1. #1
    shubhamgandhi is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jul 2011
    Posts
    22

    Syntax error on WHERE clause, possible type conflict?

    I'm trying to run this piece of



    Code:
    strSQL = "SELECT * FROM ORDER_DATA WHERE ORDER=" & curOrder
    rst_orderData = db.OpenRecordset(strSQL)
    The ORDER column from ORDER_DATA is a double number type, and curOrder is of type double as well.

    The error I'm getting points to the second line and says "Syntax error on WHERE clause".

    Why do you think this is? Is it a possible type conflict?

    Any help is appreciated! Thank you!

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,847
    Is that all of your vba?

    You should Dim the database and the recordset.

    Here's a sample just for format/syntax

    Sub testSelectByDate()
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Set db = CurrentDb
    Set rs = db.OpenRecordset("select * from Vmaintenance where Day(servicedate) = 3")
    Do While Not rs.EOF
    Debug.Print rs!servicedate
    rs.MoveNext
    Loop
    Debug.Print rs.RecordCount & " Records in Month 3"
    End Sub

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Add this between those two:

    Debug.Print strSQL

    and check the VBA Immediate window for the finished SQL. Perhaps the variable doesn't contain what you think it does.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    shubhamgandhi is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jul 2011
    Posts
    22
    No, sorry I forgot to mention this is just a snippet where the error was occuring. But I figured it out, I have to put "ORDER" in bracket as it's a reserved keyword.
    Thanks for the reply tho!

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

Similar Threads

  1. write conflict error
    By karuppasamy in forum Access
    Replies: 1
    Last Post: 06-07-2011, 12:23 PM
  2. Incomplete Syntax Clause (syntax error)
    By ajetrumpet in forum Programming
    Replies: 4
    Last Post: 09-11-2010, 10:47 AM
  3. Where clause syntax
    By stupesek in forum Reports
    Replies: 7
    Last Post: 09-03-2010, 02:26 PM
  4. Write Conflict Error Message
    By AKQTS in forum Forms
    Replies: 2
    Last Post: 07-27-2010, 09:57 AM
  5. Write Conflict Error
    By botts121 in forum Access
    Replies: 5
    Last Post: 09-25-2009, 12:11 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