Setting system time

  • Thread starter Thread starter Freddie
  • Start date Start date
F

Freddie

How would I go about setting the system date and time via vba code. Any
sites or advice would be greatly appreciated.


Fred
 
Freddie said:
How would I go about setting the system date and time via vba code. Any
sites or advice would be greatly appreciated.

From the Access 97 Help File
************************************
Date Statement
Sets the current system date.

Syntax
Date = date

For systems running Microsoft Windows 95, the required date specification must
be a date from January 1, 1980 through December 31, 2099. For systems running
Microsoft Windows NT, date must be a date from January 1, 1980 through December
31, 2079.

-------------------------------------------

Time Statement
Sets the system time.

Syntax
Time = time

The required time argument is any numeric expression, string expression, or any
combination, that can represent a time.

Remarks

If time is a string, Time attempts to convert it to a time using the time
separators you specified for your system. If it can't be converted to a valid
time, an error occurs.
************************************************
 
Rick,
Thanks, perhaps I was not clear in my question. I want to be able from
access prompt the user to enter a date and also a time interval that would
set the date and time on the computer. What would to code be in order to
perform this?

Fred
 
Freddie said:
Rick,
Thanks, perhaps I was not clear in my question. I want to be able from
access prompt the user to enter a date and also a time interval that would
set the date and time on the computer. What would to code be in order to
perform this?

Just provide prompts and feed the returns to the aforementioned statements.

Date = CDate(InputBox("Please Enter Date"))
Time = InputBox("Please Enter Time")

You would likely want to expand on the above to add tests to make sure that
valid entries are made in each case, add error handling, etc..
 
Back
Top