I am trying to update few fields in an Access Database from an Excel file through vba. The field formats are identical. However, I am facing an error message with following text:
run time error (syntax error in FROM clause)
following is my code:
Dim Wb As Workbook
Dim Ws1, Ws2 As Worksheet
Dim CN As ADODB.Connection
Dim Rst As ADODB.Recordset
Dim i As Long
Dim mySQLst As String
Dim IDd As Long
Dim dbPath
Set Wb = ThisWorkbook
Set Ws1 = Wb.Sheets("Sheet1")
dbPath = Ws1.Range("V1").Value
Set CN = New ADODB.Connection
CN.Open "Provider=microsoft.ace.oledb.12.0;data source=" & dbPath
Set Rst = New ADODB.Recordset
For i = 2 To Ws1.Range("A" & Rows.Count).End(xlUp).Row
IDd = Ws1.Cells(i, 1).Value
mySQLst = "SELECT * FROM Test_Table1 WHERE (((Test_Table1.ID1)=16));"
Rst.Open mySQLst, CN, adOpenDynamic, adLockOptimistic, Options:=adCmdTable
While Not Rst.EOF
Rst!TASK_STATUS = Ws1.Cells(i, 13).Value
Rst!TASK_COMPLETED_DATE = Ws1.Cells(i, 14).Value
Rst!RESPONSE = Ws1.Cells(i, 15).Value
Rst.MoveNext
Wend
Next i
Rst.Close
Set Rst = Nothing
CN.Close
Set CN = Nothing
End Sub
I have my activeX library 2.5 active from reference.
Thanks