opopanax666
Registered User.
- Local time
- Today, 00:57
- Joined
- Nov 2, 2006
- Messages
- 44
(solved) VBA date problem (American <-> local)
Hi everyone,
I work in Belgium (date format dd/mm/yyyy).
I have a JET table with a date field (format date/time)
I use this code to get the date and write it to the table:
Following this the date shows as "2/06/2014 12:00:05" in the table.
A bit further in the code, I use following code to retrieve this same record:
and yes, it returns an error 3021 "no current record" (= empty recordset = no date found)(variable "dteDatum" is not changed between the 2 bits of code).
When I manually create a query:
I get an empty result (and when I look at the design it shows #6/02/2014# as criteria)
When I make it:
I get my record...
Now, I get that Access has problems with the (in my view totally ridiculous) "locale"-thingy, and dates in particular, but these 2 operations are based on the same(!) variable, containing the same(!) value, and still there's a problem.
So, does anybody have some kind of solution for this? I tried using Allen Browne's SQLDate function, but that opened an other can of worms (type mismatch, error-3075, error-3421)...
TIA for any feedback!
Hi everyone,
I work in Belgium (date format dd/mm/yyyy).
I have a JET table with a date field (format date/time)
I use this code to get the date and write it to the table:
Code:
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("SELECT * FROM " & strTABEL & "", dbOpenDynaset, dbSeeChanges) '*** (dbo_)tblGEPRODUCEERD2 ***
dteDatum = Now()
rst.AddNew
rst!Geprod_ID = lngHuidigNr
rst!Weging_datum = dteDatum
rst.Update
rst.Close
Set rst = Nothing
Set dbs = Nothing
A bit further in the code, I use following code to retrieve this same record:
Code:
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("SELECT * FROM " & strTABEL & " WHERE Weging_datum = #" & dteDatum & "#", dbOpenDynaset, dbSeeChanges) '*** (dbo_)tblGEPRODUCEERD2 ***
rst.MoveFirst
rst.Edit
rst!Print_x = 1
rst.Update
rst.Close
Set rst = Nothing
Set dbs = Nothing
When I manually create a query:
Code:
SELECT * FROM tblGEPRODUCEERD2 WHERE Weging_datum = #2/06/2014#;
When I make it:
Code:
SELECT * FROM tblGEPRODUCEERD2 WHERE Weging_datum = #6/02/2014#;
Now, I get that Access has problems with the (in my view totally ridiculous) "locale"-thingy, and dates in particular, but these 2 operations are based on the same(!) variable, containing the same(!) value, and still there's a problem.
So, does anybody have some kind of solution for this? I tried using Allen Browne's SQLDate function, but that opened an other can of worms (type mismatch, error-3075, error-3421)...
TIA for any feedback!
Last edited: