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. #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!

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 18 Times in 18 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
  •