• Syntax error in FROM clause (Access 2003)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Syntax error in FROM clause (Access 2003)

    Author
    Topic
    #450965

    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! confused

    Viewing 0 reply threads
    Author
    Replies
    • #1109113

      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!

      • #1109121

        Shouldn’t that be

        strCriteria = “SELECT * FROM tblCompoundAssignments WHERE …

    Viewing 0 reply threads
    Reply To: Syntax error in FROM clause (Access 2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: