MS Windows XP Pro
This has caused me a lot of hair loss in the last few days so would
appreciate any help.
I am running code to append/update a local access database from a
remote MS SQL database. The method of determining which records to
append is primarily using the last date an update was carried out; I
appreciate that there is probably a better way of doing this but time
contraints prevent me from doing extensive research and dev at the
moment. Below is a section of code from the procedure where
tblLastUpdate is a 2 field single record table used to store the date
the database was last updated.
Dim dateLastUpdate As Date
Dim dateNewUpdate As Date
Dim dateCurrentDate As Date
Dim stUpdateLastUpdateSQL As String
dateLastUpdate = DLookup("LastUpdate", "tblLastUpdate", "DateID = 1")
dateNewUpdate = dateLastUpdate - 1
dateCurrentDate = Date
stUpdateLastUpdateSQL = "UPDATE tblLastUpdate SET
tblLastUpdate.LastUpdate = #" & dateCurrentDate & "#" & _
"WHERE (((tblLastUpdate.DateID)=1));"
DoCmd.RunSQL stUpdateLastUpdateSQL
Now the problem is that when this code runs the dateCurrentDate
variable is set correctly at e.g. 08/04/05 and having stepped through
the code this remains correct all the way through, but after the SQL
statement is executed the LastUpdate field is populated with 04/08/05.
This is not simply a case of date formatting on the table as when this
new date is run through the code again the dateNewUpdate variable is
set to 03/08/05.
I have checked all regional settings bith in access and windows and
they all appear to be fine.
Thanks in advance
Matt