ADODB SQL help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can anyone here tell me what is wrong with my SQL statement? I get a error of
Expected 1.

Sub UpdateData2()
On Error GoTo ErrorHandler

Dim MyCn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim strSQL As String

Set MyCn = New ADODB.Connection

' Replace actual Access file path here
MyCn.Open "DRIVER={Microsoft Access Driver (*.mdb)};" _
& "DBQ=G:\TestCQA.mdb"

Set rst = New ADODB.Recordset

strSQL = "SELECT * FROM tblExcel" _
& " WHERE tblExcel.TestID = " & Range("A2").Value

rst.Open strSQL, MyCn

If rst!IsReviewed = False Then 'no edit statement here?
rst!IsReviewed = True
rst.Update
End If

MyCn.Close

ErrorHandler_Exit:
Set MyCn = Nothing
Exit Sub

ErrorHandler:
MsgBox Err.Description
GoTo ErrorHandler_Exit

End Sub
 
You may need to put single quotes around the Range.Value if its text
ie,
" WHERE tblExcel.TestID = '" & Range("A2").Value & "'"

either that or tblExcel.TestID doesn't exist
 
Back
Top