0

The error I am getting is Syntax error in where clause in Access.

Here is the code:

SQL = "Select * FROM tblPermitAgencyInformation  & WHERE [RecordID] = " & Me.AgencyInfoRecordID.Value
Set rs = db.OpenRecordset(SQL)

RecordID is an autonumber field and the AgencyInfoRecordID is an integer.

Andre
  • 26,751
  • 7
  • 36
  • 80
JimP
  • 21
  • 4

1 Answers1

0

It looks like you misread the article you state. It appears to be attempting to format the adhoc query in the text variable. Note: it says

strSQL = "SELECT wazzle FROM bamsploot" & vbCrLf & " WHERE plumsnooker = 0"

You need to make sure that you have the ampersands outside of the quotes, (they are used to append variables and strings together in this case)

Follow June7 advice and remove the ampersand there. It should help you get running.

Make your code this:

SQL = "Select * FROM tblPermitAgencyInformation WHERE [RecordID] = " & Me.AgencyInfoRecordID.Value

Hope that helps

xDJR1875
  • 280
  • 1
  • 18