Server Date

A

Anand

I am using a multi user A2k db application that has a
backend/frontend config. The app uses date/time functions
like date() and now().

My problem is that the date and time settings on the
frontend computers may be unreliable or subject to changes
by the user. I would like to use the date and time
settings on the Server in VBA code of the frontend.

Can this be done? If so, how?

TIA
Anand
 
C

Chadlon

Hi Anand,

There are at least two approaches, both of which involve changing the system
clock on the front-end computer. So the initial question is 'has this been
cleared with system admin'?

Assuming all that's OK, method 1 is to force clock synchronisation as part
of the standard system log-on script, so that all workstations pick up their
time from a/the system server. A variation on that - if there is a broadband
connection - is to have all machines sync their clocks using an internet
time server (Windows XP has this as a built-in optional feature ... see Help
'synchronise clocks')

Method 2 is to organise it yourself at db session startup ...
(a) discover the identity of the backend host
(b) take a snapshot of the local machine time
(c) synchronise to backend server time
(d) .... db session progresses ....
(e) at end of db session, restore original local clock (adjusted for
elapsed time)

The backend path can be obtained from the connect string of a linked table.
If that's a UNC-type string - starts with \\ServerName ... that gives you
the name of the server
If it is a drive letter to a mapped drive, then you need to discover the
host name by using the Windows API call WNetGetConnection32.

Having obtained the server name, you can use the "Net Time" command to set
the clock of the local machine ...
Something like
hostCompName$ = "\\ServerName "
appName$ = "command.com /c Net time " & hostCompName$ & " /set /yes
"
hMod = Shell(appName$, vbHide)

Good Luck,
CD
 
A

Anand

Hi Chadlon
Thanks for the tip. I tried the second method since I
have no experience in programming Windows.

I guess I need a little more help with the sample code you
gave me. I tried to run it in VBA by passing the server
name and when the code executed the hmod variable returned
a number but I cant seem to figure out what to do with
it. Can you tell me where I can find more info about this
Net Time command?

Thanks a bunch
Anand
-----Original Message-----
Hi Anand,

There are at least two approaches, both of which involve changing the system
clock on the front-end computer. So the initial question is 'has this been
cleared with system admin'?

Assuming all that's OK, method 1 is to force clock synchronisation as part
of the standard system log-on script, so that all workstations pick up their
time from a/the system server. A variation on that - if there is a broadband
connection - is to have all machines sync their clocks using an internet
time server (Windows XP has this as a built-in optional feature ... see Help
'synchronise clocks')

Method 2 is to organise it yourself at db session startup ...
(a) discover the identity of the backend host
(b) take a snapshot of the local machine time
(c) synchronise to backend server time
(d) .... db session progresses ....
(e) at end of db session, restore original local clock (adjusted for
elapsed time)

The backend path can be obtained from the connect string of a linked table.
If that's a UNC-type string - starts with
\\ServerName ... that gives you
 
C

Chadlon

Anand,
Here's the good news ....

If you've got as far as wondering 'what to do with' hMod, then you've
already reached your objective.
Specifically, if you check out the local time on the w/stn you are running,
it should now be synch'd with the chosen server (aka any other machine).

For the detail ...
the hMod is a return value from the Shell command - check it out using
Access Help (e.g. place the cursor on the word Shell and press F1).

The command group "Net" is a large collection of things to do with
interrogating and controlling the network. Open up a Command Prompt window
(aka DOS box) and type the command
Net /?
That gets you a list of the many options supported by the Net command. For
more detail, pick any one or the options and again ask for help, as in:
Net Time /?
The detail of the output (and syntax) varies a little from one OS to
another. An XP Pro machine output is shown below, and for comparison the
equivalent from a W98se machine

Good Luck
CD

' ======== sample output from XP Pro DOS box .....
C:\>net /?
The syntax of this command is:

NET [ ACCOUNTS | COMPUTER | CONFIG | CONTINUE | FILE | GROUP | HELP |
HELPMSG | LOCALGROUP | NAME | PAUSE | PRINT | SEND | SESSION |
SHARE | START | STATISTICS | STOP | TIME | USE | USER | VIEW ]


C:\>Net Time /?
The syntax of this command is:

NET TIME
[\\computername | /DOMAIN[:domainname] | /RTSDOMAIN[:domainname]] [/SET]
[\\computername] /QUERYSNTP
[\\computername] /SETSNTP[:ntp server list]

Displays the time on or synchronizes your computer's
clock with the shared clock on a Microsoft Windows for
Workgroups, Windows NT, Windows 95, or NetWare
time server.

' ======== sample output from W98se DOS box .....
C:\>net /?
For more information about a specific Microsoft NET
command, type the command name followed by /?
(for example, NET VIEW /?).

NET CONFIG Displays your current workgroup settings.
NET DIAG Runs the Microsoft Network Diagnostics program to
display diagnostic information about your network.
NET HELP Provides information about commands and
error messages.
NET INIT Loads protocol and network-adapter drivers without
binding them to Protocol Manager.
NET LOGOFF Breaks the connection between your computer and
the shared resources to which it is connected.
NET LOGON Identifies you as a member of a workgroup.
NET PASSWORD Changes your logon password.
NET PRINT Displays information about print queues
and controls print jobs.
NET START Starts services.
NET STOP Stops services.
NET TIME Displays the time on or synchronizes your computer's
clock with the clock on a Microsoft Windows for
Workgroups, Windows NT, Windows 95, or NetWare time server.
NET USE Connects to or disconnects from a shared
resource or displays information about
connections.
NET VER Displays the type and version number of the
workgroup redirector you are using.
NET VIEW Displays a list of computers that share
resources or a list of shared resources
on a specific computer.


C:\>Net Time /?
NET TIME [\\computer | /WORKGROUP:wgname] [/SET] [/YES]

computer Specifies the name of the computer (time
server) whose time you want to check or
synchronize your computer's clock with.
/WORKGROUP Specifies that you want to use the clock on a
computer (time server) in another workgroup.
wgname Specifies the name of the workgroup containing
a computer whose clock you want to check or
synchronize your computer's clock with. If
there are multiple time servers in that
workgroup, NET TIME uses the first one it
finds.
/SET Synchronizes your computer's clock with the
clock on the computer or workgroup you
specify.
/YES Carries out the NET TIME command without
first prompting you to provide information or
confirm actions.
 
A

Anand

Hi Chadlon,
I hadnt realized that I'd already achieved the objective
when I executed the code in my testing computer. It works
brilliantly on other computers where the local system
clock is lagging or leading.

Thanks again
Anand
-----Original Message-----
Anand,
Here's the good news ....

If you've got as far as wondering 'what to do with' hMod, then you've
already reached your objective.
Specifically, if you check out the local time on the w/stn you are running,
it should now be synch'd with the chosen server (aka any other machine).

For the detail ...
the hMod is a return value from the Shell command - check it out using
Access Help (e.g. place the cursor on the word Shell and press F1).

The command group "Net" is a large collection of things to do with
interrogating and controlling the network. Open up a Command Prompt window
(aka DOS box) and type the command
Net /?
That gets you a list of the many options supported by the Net command. For
more detail, pick any one or the options and again ask for help, as in:
Net Time /?
The detail of the output (and syntax) varies a little from one OS to
another. An XP Pro machine output is shown below, and for comparison the
equivalent from a W98se machine

Good Luck
CD

' ======== sample output from XP Pro DOS box .....
C:\>net /?
The syntax of this command is:

NET [ ACCOUNTS | COMPUTER | CONFIG | CONTINUE | FILE | GROUP | HELP |
HELPMSG | LOCALGROUP | NAME | PAUSE | PRINT | SEND | SESSION |
SHARE | START | STATISTICS | STOP | TIME | USE | USER | VIEW ]


C:\>Net Time /?
The syntax of this command is:

NET TIME
[\\computername | /DOMAIN[:domainname] | /RTSDOMAIN [:domainname]] [/SET]
[\\computername] /QUERYSNTP
[\\computername] /SETSNTP[:ntp server list]

Displays the time on or synchronizes your computer's
clock with the shared clock on a Microsoft Windows for
Workgroups, Windows NT, Windows 95, or NetWare
time server.

' ======== sample output from W98se DOS box .....
C:\>net /?
For more information about a specific Microsoft NET
command, type the command name followed by /?
(for example, NET VIEW /?).

NET CONFIG Displays your current workgroup settings.
NET DIAG Runs the Microsoft Network Diagnostics program to
display diagnostic information about your network.
NET HELP Provides information about commands and
error messages.
NET INIT Loads protocol and network-adapter drivers without
binding them to Protocol Manager.
NET LOGOFF Breaks the connection between your computer and
the shared resources to which it is connected.
NET LOGON Identifies you as a member of a workgroup.
NET PASSWORD Changes your logon password.
NET PRINT Displays information about print queues
and controls print jobs.
NET START Starts services.
NET STOP Stops services.
NET TIME Displays the time on or synchronizes your computer's
clock with the clock on a Microsoft Windows for
Workgroups, Windows NT, Windows 95, or NetWare time server.
NET USE Connects to or disconnects from a shared
resource or displays information about
connections.
NET VER Displays the type and version number of the
workgroup redirector you are using.
NET VIEW Displays a list of computers that share
resources or a list of shared resources
on a specific computer.


C:\>Net Time /?
NET TIME [\\computer | /WORKGROUP:wgname] [/SET] [/YES]

computer Specifies the name of the computer (time
server) whose time you want to check or
synchronize your computer's clock with.
/WORKGROUP Specifies that you want to use the clock on a
computer (time server) in another workgroup.
wgname Specifies the name of the workgroup containing
a computer whose clock you want to check or
synchronize your computer's clock with. If
there are multiple time servers in that
workgroup, NET TIME uses the first one it
finds.
/SET Synchronizes your computer's clock with the
clock on the computer or workgroup you
specify.
/YES Carries out the NET TIME command without
first prompting you to provide information or
confirm actions.




Hi Chadlon
Thanks for the tip. I tried the second method since I
have no experience in programming Windows.

I guess I need a little more help with the sample code you
gave me. I tried to run it in VBA by passing the server
name and when the code executed the hmod variable returned
a number but I cant seem to figure out what to do with
it. Can you tell me where I can find more info about this
Net Time command?

Thanks a bunch
Anand
involve
changing the system question
is 'has this been string
of a linked table.
\\ServerName ... that gives you need
to discover the


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top