UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Change System Date via VBA    
 
   
mac_baum
post Jul 31 2004, 03:40 PM
Post#1



Posts: 81
Joined: 28-November 02
From: Canada


Is there any way to change the system date from VBA code? I need to go back one month.However, a general solution would be appreciated ie change day/month/year.
Thanks for your help.
Go to the top of the page
 
truittb
post Jul 31 2004, 04:04 PM
Post#2


Retired Moderator
Posts: 13,563
Joined: 23-June 02
From: Texas (Is there anywhere else?)


How about
ate() = #7/31/2004#
For you could use a variable
Date() = dtmYourDate
Go to the top of the page
 
r_cubed
post Jul 31 2004, 07:15 PM
Post#3


UtterAccess VIP
Posts: 3,752
Joined: 8-November 02
From: Australia (NSW)


Do you know, Truitt ..... when I saw YOUR example, I thought ... "NO, this would/should throw an error. Changing system date should NOT be that simple (read dangerous)."
Just tried it , and it worked , for BOTH Date (and Time , as I found out via the : Time() = #11:10:00 AM#).
Is this dangerous .... ????? . Not sure, but it does it !!!
Not sure why you would want to, but you learn something new every day.
Go to the top of the page
 
truittb
post Jul 31 2004, 09:34 PM
Post#4


Retired Moderator
Posts: 13,563
Joined: 23-June 02
From: Texas (Is there anywhere else?)


It suprised me too. It was Saturday afternoon and I was bored and just tried it.
Ocan't think of any legitimate reason to use it, unless you want to set the date/time to match the date/time on another server or website.
Go to the top of the page
 
truittb
post Jul 31 2004, 09:42 PM
Post#5


Retired Moderator
Posts: 13,563
Joined: 23-June 02
From: Texas (Is there anywhere else?)


Just looked at VBA's help and it is a documented method<
Go to the top of the page
 
mishej
post Jul 31 2004, 11:14 PM
Post#6


Retired Moderator
Posts: 11,289
Joined: 25-September 02
From: Milwaukee, WI


Probably not as dangerous as the Shell() command. Setting the date requires specific permissions in MS's business OS's that should prevent unauthorized users from changing the time.
Go to the top of the page
 
kenick
post Aug 2 2004, 07:12 AM
Post#7



Posts: 989
Joined: 1-August 02
From: Kansas City, MO, USA


I looked at Truitt's example and tried the same thing with time: Time = #6:56:00 AM# and it worked also. I noticed that the example didn't have the () after the date or time. It's another reason to warn people about what names they use in their tables. If you have fields in your tables called Date or Time and try to assign values to them, it seems possible that you could be changing your system settings instead.
Go to the top of the page
 
truittb
post Aug 2 2004, 08:34 AM
Post#8


Retired Moderator
Posts: 13,563
Joined: 23-June 02
From: Texas (Is there anywhere else?)


Good point. It is always nice to have a concrete example of why reserved words should be avoided.
Go to the top of the page
 
Gustav
post Feb 7 2012, 04:03 AM
Post#9


UtterAccess VIP
Posts: 2,163
Joined: 21-February 07



Set up a separate machine not connected to corporate LAN with duplicates of your date.
Anything else will force you into trouble.
gustav
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    30th August 2015 - 11:42 PM