Even after reviewing earlier posts and MS Learn on this topic, I'm still struggling to get an SQL INSERT query to behave the way I want it to. Using Access 365 under Windows 11 24H2.
After creating in VBA a new temporary password for a user, I need to insert today's date as an expiry date into a password table. Originally I had forgotten abouty SQL's insistance on American dates, so I wrote
That obviously failed because the Date function and SQL talk different landuages, so I changed the first line to
This appears to work - Debug prints Expiry as 8/03/2025, and VarType(Expiry) shows it to be a date value (type 7). But later I need to display a list of people with their expiry dates, and when I format the expiry date in the table as a medium date, it shows it to be 03-Aug-25. How can I get it to stay in the format Date() gave me - the UK/Australian format?
After creating in VBA a new temporary password for a user, I need to insert today's date as an expiry date into a password table. Originally I had forgotten abouty SQL's insistance on American dates, so I wrote
Code:
Expiry = Date ' Set it to expire immediately strSQL = "INSERT INTO AccessAuthority (PersonID, AccessLevel, Admin, Hash, Key, Expiry) " _ & "VALUES (" & PersonID & ", " & AccessLevel & ", " & FrameAdmin & ", '" & Hash & "', 0, #" & Expiry & "#);" Debug.Print FirstName, Expiry, strSQL CurrentDb.Execute strSQL ' Enter the record in the Access Authority table
Code:
Expiry = Format(Date, "YYYY-MM-DD") ' Set it to expire immediately
Comment