Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Jan 2008
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Syntax error in FROM clause (Access 2003)

    Here's my code. I hope someone can help.
    Dim Connxn As ADODB.Connection
    Dim rst As ADODB.Recordset
    Set Connxn = CurrentProject.Connection
    Set rst = New ADODB.Recordset
    strCriteria = "SELECT * FROM tblCompoundAssignments WHERE [tblCompoundAssignments].[Compound] = '" & Me.CompoundNo & "'"
    rst.Open strCriteria, Connxn, adOpenDynamic, adLockPessimistic, adCmdTable

    I get the error message on the rst.Open line. What am I doing wrong?

    Things were okay until I tried to add the WHERE clause. Earlier I was just opening the table and had added the line
    rst.filter = "[Compound] = " & me.compoundno
    once the table was open, but it wasn't actually performing the filter for some reason, so I thought it would be better to restrict the records up front.

    Help! <img src=/S/confused.gif border=0 alt=confused width=15 height=20>

  2. Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Lounger
    Join Date
    Jan 2008
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Syntax error in FROM clause (Access 2003)

    Well, I figured it out on my own.
    For those reading this thread, I should have written:
    strCriteria = "tblCompoundAssignments WHERE (([Compound] )= '" & Me.CompoundNo & "')"

    If I had followed earlier instructions from Hans, I believe, I would not have had this problem!

  4. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Syntax error in FROM clause (Access 2003)

    Shouldn't that be

    strCriteria = "SELECT * FROM tblCompoundAssignments WHERE ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •