I am getting an error when attempting to execue a dynamic sql string in MS Access (I am using VBA to write the code).
Error:
Run-time error '3075': Syntax error (missing operator) in query expression "11/8/2013' FROM tbl_sample'.
Here is my code:
Sub UpdateAsOfDate()
Dim AsOfDate As String
AsOfDate = Form_DateForm.txt_AsOfDate.Value
AsOfDate = Format(CDate(AsOfDate))
Dim dbs As Database
Set dbs = OpenDatabase("C:\database.mdb")
Dim strSQL As String
strSQL = " UPDATE tbl_sample " _
& "SET tbl_sample.As_of_Date = '" _
& AsOfDate _
& "' " _
& "FROM tbl_sample " _
& "WHERE tbl_sample.As_of_Date IS NULL ;"
dbs.Execute strSQL
dbs.Close
End Sub
I piped the strSQL to a MsgBox so I could see the finished SQL string, and it looks like it would run without error. What's going on?
"FROMis not valid inUPDATE