Hi, all.
I'm trying to do an update on a database using an SQL statement built from a string. What's wrong with this code snippet?
Sub addDate()
Dim db As Database
Dim qdf As QueryDef
Dim mySQL As String
Dim lastMonth As Integer
Dim reportYear As Integer
lastMonth = Form_ReportMonth.myMonth
reportYear = Form_ReportMonth.myYear
Set db = OpenDatabase("c:\TruckReport\TruckReport.mdb")
Set qdf = db.CreateQueryDef("")
mySQL = "UPDATE costRecord SET costRecord.[Date] = #" & CStr(lastMonth) & "/1/" & CStr(reportYear) & "#;"
qdf.SQL = mySQL
qdf.Execute <--- crashes here, can't find table????
qdf.Close
db.Close
End Sub
Thanks
PB
I'm trying to do an update on a database using an SQL statement built from a string. What's wrong with this code snippet?
Sub addDate()
Dim db As Database
Dim qdf As QueryDef
Dim mySQL As String
Dim lastMonth As Integer
Dim reportYear As Integer
lastMonth = Form_ReportMonth.myMonth
reportYear = Form_ReportMonth.myYear
Set db = OpenDatabase("c:\TruckReport\TruckReport.mdb")
Set qdf = db.CreateQueryDef("")
mySQL = "UPDATE costRecord SET costRecord.[Date] = #" & CStr(lastMonth) & "/1/" & CStr(reportYear) & "#;"
qdf.SQL = mySQL
qdf.Execute <--- crashes here, can't find table????
qdf.Close
db.Close
End Sub
Thanks
PB