Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get time from server computer using VBA ? 1

Status
Not open for further replies.

Webkins

Programmer
Dec 11, 2008
118
US
I have an Access 2003 program in which I would like to get the Now() time from a server computer and not the local computer on which the Access database application is running. I am trying to prevent the user from changing the time and date on the local computer and obtaining access to files after a set number of days. Is this possible ?

Thank you for any assistance in advance.
 
what sort of server? a database server such as SQL server, Oracle, MySQL etc? an internet (NTP) time server?

John
 
The server I am trying to connect to is a Local server running Windows 2003 server and MSSql 2000. I never thought of that but I could return the time using a MSSql query as well, correct ?
 
I don't have any idea where this data is stored or can be retrieved from. Any ideas ?
 
getdate()

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Write a function that executes the shell command "NET TIME \\server /SET" then follows with Now(). Run this at start up. You could check Now() against the startup Now() to make sure it's later to watch for users changing system time after startup.

If this is a system that's running 24/7 you could call the function on form load or on a timer or something. You get the added benefit of constantly correcting the time and frustrating the miscreants. ;-)


Jeff
[small][purple]It's never too early to begin preparing for [/purple]International Talk Like a Pirate Day
"The software I buy sucks, The software I write sucks. It's time to give up and have a beer..." - Me[/small]
 
This response is way off topic for an Access forum, but if the server is part of an active directory domain you can use NET TIME \\server
to retrieve it from one of the domain controllers (replacing \\server with the name of a DC), but then all systems have to be within 5 minutes anyway for the Kerberos authentication to work.

If it isn't you can always set an NTP time server on the Windows Time tab of the date/time control panel, then Windows handles the time syncing and you can get away with just calling Now() from your VBA code.

PHV's answer will work if you can get the details from a Microsoft SQL Server. Either connect via ADO or use a pass through query through ODBC to connect.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top