ADODB SQL help


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
 
Ad

Advertisements

D

David Welch

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top