Hi chaps,
I am having trouble trying to update a record in a table using UPDATE to update from the value of LastDateVar to the value of TodaysDateVar.
The code I am using is:
The first two line of the code is to open the table TBLDatabaseDate to find the value of the record DatabaseDate, this works fine.
The next line
gives a Syntax Error and I cannot see where.
What am I doing wrong?
Any suggestions?
Inky
A fool and his money are soon parted - so you might as well send it to me!
I am having trouble trying to update a record in a table using UPDATE to update from the value of LastDateVar to the value of TodaysDateVar.
The code I am using is:
Code:
Dim FindLastDate As New ADODB.Recordset
Dim conn As ADODB.Connection
Set conn = CurrentProject.Connection
Dim updateCommand As String
FindLastDate.Open "SELECT DatabaseDate FROM TBLDatabaseDate", conn
LastDateVar = FindLastDate("DatabaseDate").Value
updateCommand = "UPDATE TBLDatabaseDate SET DatabaseDate = " & TodaysDateVar & " WHERE DatabaseDate = '" & LastDateVar & "'"
conn.Execute updateCommand
FindLastDate.Close
The first two line of the code is to open the table TBLDatabaseDate to find the value of the record DatabaseDate, this works fine.
The next line
Code:
updateCommand = "UPDATE TBLDatabaseDate SET DatabaseDate = " & TodaysDateVar & " WHERE DatabaseDate = '" & LastDateVar & "'"
gives a Syntax Error and I cannot see where.
What am I doing wrong?
Any suggestions?
Inky
A fool and his money are soon parted - so you might as well send it to me!