Did you know that you can change the PCs date and time from VBA code?
I didn’t. Until I read The Daily WTF article Trans-Atlantic Time Trap. There’s a link leading to a 2004 thread on this topic Change System Date via VBA. Glad to see that fellow Access MVP Truitt B got bored one Saturday Note that one poster commented that if you used Date and Time as the names of fields in tables or controls on forms or reports you could have issues.
I tried just the following VBA code on my Windows 7 system and received a Permission Denied error message which is, in my opinion, quite reasonable.
date = #2012-01-01#
If I run Access as an administrator it does let me change the date. (I very quickly changed it back.)
I then tried creating a control named Date on a form and then assigned it a string value.
Date = “test”
I then got a Type MisMatch message. Which makes sense once you realize what is happening.
Next I tried
me.Date = “text”
but this gave me an Invalid use of Me Keyword. Which also makes sense too. But very, very confusing to someone who doesn’t realize that these are reserved words.
Speaking of reserved words a friend was happily working on a timesheet system using a table called Union. Which worked just fine for months until he had to create a union query using that table.
For the definitive list see Allen Browne’s Problem names and reserved words in Access.