By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,715 Members | 1,815 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,715 IT Pros & Developers. It's quick & easy.

Race Time Part II

P: n/a
Today’s question involves two time text boxes each set to a different time
zone. Initially txtCurrentTime will be set to Pacific Time or system time.
This will change with system time as we travel across the country.
txtRaceTime will always be set to Central Time regardless of where we are in
the US.

At first I tried ‘Now() – “xx:xx:xx” but that produced an error. Anyway as
we approach the east coast the ‘minus’ would need to be a ‘plus’.

Ideally the solution would simply put the current computer time, regardless
of location, in the first text box and automatically put Central Time in the
second.

Any simple solutions? Thank you
B.
Nov 13 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
"Rebecca Smith" <rp*****@pcez.com> wrote in
news:10*************@corp.supernews.com:
Today’s question involves two time text boxes each set to a different
time zone. Initially txtCurrentTime will be set to Pacific Time or
system time. This will change with system time as we travel across the
country. txtRaceTime will always be set to Central Time regardless of
where we are in the US.


It's 21:25 (9:25 pm). Do you know where you computer is tonight?
--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 13 '05 #2

P: n/a
"Lyle Fairfield" wrote
It's 21:25 (9:25 pm). Do you know where
you computer is tonight?


Good one, Lyle.

Nov 13 '05 #3

P: n/a
Hi Rebecca,

I'm assuming that your PC is set to Central Time.
If not, I'm sure that you'll be able to correct the pattern in the code
below.

Try this:

A form containing 2 textboxes:
txtCentral Time -- Control Source: =Now() -- Format: LongTime
txtLocalTime -- Control Source: Unbound -- Format: LongTime

Now add an option group ("optTimeZone") containing the 7 time zones, and add
the code below to the form's On Timer event (Interval = 1000 ms)
Selecting a time zone from the option group will display the correct time
for that region in txtLocalTime.
********************************
Private Sub Form_Timer()

Select Case optTimeZone

Case 1 'Alaska
Me.txtLocalTime = DateAdd("h", -3, Now())
Case 2 'Pacific
Me.txtLocalTime = DateAdd("h", -2, Now())
Case 3 'Mountain
Me.txtLocalTime = DateAdd("h", -1, Now())
Case 4 'Central
Me.txtLocalTime = Now()
Case 5 'Eastern
Me.txtLocalTime = DateAdd("h", 1, Now())
Case 6 'Atlantic
Me.txtLocalTime = DateAdd("h", 2, Now())
Case 7 'Newfoundland

'Newfies are 2.5 hr later than Central, and DateAdd wont work with
fractions
Me.txtLocalTime = DateAdd("n", 150, Now())

End Select

Me.Recalc

End Sub
********************************
--
HTH,
Don
=============================
Use My*****@Telus.Net for e-mail
Disclaimer:
Professional PartsPerson
Amateur Database Programmer {:o)

I'm an Access97 user, so all posted code
samples are also Access97- based
unless otherwise noted.

Do Until SinksIn = True
File/Save, <slam fingers in desk drawer>
Loop

================================

"Rebecca Smith" <rp*****@pcez.com> wrote in message
news:10*************@corp.supernews.com...
Today's question involves two time text boxes each set to a different time
zone. Initially txtCurrentTime will be set to Pacific Time or system time.
This will change with system time as we travel across the country.
txtRaceTime will always be set to Central Time regardless of where we are in the US.

At first I tried 'Now() - "xx:xx:xx" but that produced an error. Anyway as
we approach the east coast the 'minus' would need to be a 'plus'.

Ideally the solution would simply put the current computer time, regardless of location, in the first text box and automatically put Central Time in the second.

Any simple solutions? Thank you
B.

Nov 13 '05 #4

P: n/a
Sorry...

I no sooner hit "send" and realized "Naw waitasec.... that's not gonna work
all the time... crap!"

In the summer months, Mountain and Central time are the same!
You'll have to factor the current date into the equation and adjust it
somewhere...

"Don Leverton" <le****************@telusplanet.net> wrote in message
news:Guwuc.10567$ig5.4715@edtnps89...
Hi Rebecca,

I'm assuming that your PC is set to Central Time.
If not, I'm sure that you'll be able to correct the pattern in the code
below.

Try this:

A form containing 2 textboxes:
txtCentral Time -- Control Source: =Now() -- Format: LongTime
txtLocalTime -- Control Source: Unbound -- Format: LongTime

Now add an option group ("optTimeZone") containing the 7 time zones, and add the code below to the form's On Timer event (Interval = 1000 ms)
Selecting a time zone from the option group will display the correct time
for that region in txtLocalTime.
********************************
Private Sub Form_Timer()

Select Case optTimeZone

Case 1 'Alaska
Me.txtLocalTime = DateAdd("h", -3, Now())
Case 2 'Pacific
Me.txtLocalTime = DateAdd("h", -2, Now())
Case 3 'Mountain
Me.txtLocalTime = DateAdd("h", -1, Now())
Case 4 'Central
Me.txtLocalTime = Now()
Case 5 'Eastern
Me.txtLocalTime = DateAdd("h", 1, Now())
Case 6 'Atlantic
Me.txtLocalTime = DateAdd("h", 2, Now())
Case 7 'Newfoundland

'Newfies are 2.5 hr later than Central, and DateAdd wont work with
fractions
Me.txtLocalTime = DateAdd("n", 150, Now())

End Select

Me.Recalc

End Sub
********************************
--
HTH,
Don
=============================
Use My*****@Telus.Net for e-mail
Disclaimer:
Professional PartsPerson
Amateur Database Programmer {:o)

I'm an Access97 user, so all posted code
samples are also Access97- based
unless otherwise noted.

Do Until SinksIn = True
File/Save, <slam fingers in desk drawer>
Loop

================================

"Rebecca Smith" <rp*****@pcez.com> wrote in message
news:10*************@corp.supernews.com...
Today's question involves two time text boxes each set to a different time zone. Initially txtCurrentTime will be set to Pacific Time or system time. This will change with system time as we travel across the country.
txtRaceTime will always be set to Central Time regardless of where we are
in
the US.

At first I tried 'Now() - "xx:xx:xx" but that produced an error. Anyway

as we approach the east coast the 'minus' would need to be a 'plus'.

Ideally the solution would simply put the current computer time,

regardless
of location, in the first text box and automatically put Central Time in

the
second.

Any simple solutions? Thank you
B.


Nov 13 '05 #5

P: n/a
Hi Chuck,
Thanks for that, but knowing how to implement API calls is still quite a bit
over my head. :(

I was just looking at the Access Web, and found a downloadable MDB file
created by Pedro Gil. http://www.mvps.org/access/forms/frm0051.htm
I think that may be just what Rebecca might be looking for. She probably
doesn't need as many time zones as are available in the combo-box, so I
modified Pedro's function so that it displays only the zones that she'll
likely be interested in.

************************************************** *****************
'Utilities for the Form
Private Function EnumRegKeys(ByVal hKey As Long) As String
'Fill the Combo Box with the TimeZone Descriptions
Dim strSubKey As String
Dim lngSubKeyCount As Long
Dim lngSubKeyMaxLen As Long
Dim lngSubKeyLen As Long
Dim lngRet As Long
Dim intCount As Integer
Dim strTemp As String
'Begin Modification by Don ----------------------------------
' This is the original list of time zones:
'*************************************************
' Afghanistan Standard Time;Alaskan Standard Time;
' Arab Standard Time;Arabian Standard Time;Arabic Standard Time;
' Atlantic Standard Time;AUS Central Standard Time;
' AUS Eastern Standard Time;Azores Standard Time;
' Canada Central Standard Time;Cape Verde Standard Time;
' Caucasus Standard Time;Cen. Australia Standard Time;
' Central America Standard Time;Central Asia Standard Time;
' Central Europe Standard Time;Central European Standard Time;
' Central Pacific Standard Time;Central Standard Time;
' China Standard Time;Dateline Standard Time;E. Africa Standard Time;
' E. Australia Standard Time;E. Europe Standard Time;
' E. South America Standard Time;Eastern Standard Time;Egypt Standard Time;
' Ekaterinburg Standard Time;Fiji Standard Time;FLE Standard Time;
' GMT Standard Time;Greenland Standard Time;Greenwich Standard Time;
' GTB Standard Time;Hawaiian Standard Time;India Standard Time;
' Iran Standard Time;Israel Standard Time;Korea Standard Time;
' Mexico Standard Time;Mexico Standard Time 2;Mid-Atlantic Standard Time;
' Mountain Standard Time;Myanmar Standard Time;N. Central Asia Standard
Time;
' Nepal Standard Time;New Zealand Standard Time;Newfoundland Standard Time;
' North Asia East Standard Time;North Asia Standard Time;Pacific SA Standard
Time;
' Pacific Standard Time;Romance Standard Time;Russian Standard Time;
' SA Eastern Standard Time;SA Pacific Standard Time;SA Western Standard
Time;
' Samoa Standard Time;SE Asia Standard Time;Singapore Standard Time;
' South Africa Standard Time;Sri Lanka Standard Time;Taipei Standard Time;
' Tasmania Standard Time;Tokyo Standard Time;Tonga Standard Time;
' US Eastern Standard Time;US Mountain Standard Time;Vladivostok Standard
Time;
' W. Australia Standard Time;W. Central Africa Standard Time;W. Europe
Standard Time;
' West Asia Standard Time;West Pacific Standard Time;Yakutsk Standard Time
'*************************************************
Dim MyZones As String
MyZones = "Alaskan Standard Time;Atlantic Standard Time;Canada Central
Standard Time;Central Standard Time;"
MyZones = MyZones & "Eastern Standard Time;Mountain Standard
Time;Newfoundland Standard Time;"
MyZones = MyZones & "Pacific Standard Time;US Eastern Standard Time;US
Mountain Standard Time;"

lngRet = apiRegQueryInfoKey(hKey, vbNullString, 0&, 0&, lngSubKeyCount, _
lngSubKeyMaxLen, 0&, 0&, 0&, 0&, 0&, 0&)
For intCount = 0 To lngSubKeyCount - 1
strSubKey = Space$(lngSubKeyMaxLen)
lngSubKeyLen = Len(strSubKey) + 1
lngRet = apiRegEnumKeyEx(hKey, intCount, strSubKey, lngSubKeyLen, _
0&, vbNullString, 0&, 0&)

If InStr(1, MyZones, Left(strSubKey, lngSubKeyLen), vbTextCompare) > 0 Then

strTemp = strTemp & Left(strSubKey, lngSubKeyLen) & ";"
End If
'Debug.Print strTemp
'End Modification by Don ----------------------------------

Next 'intCount
EnumRegKeys = Left(strTemp, Len(strTemp) - 1)
End Function
************************************************** *****************

"Chuck Grimsby" <c.*******@worldnet.att.net.invalid> wrote in message
news:c0********************************@4ax.com...

Hey, Don... The GetTimeZoneInformation API call will get all that
information for you.

<previous posts snipped> DL

--
HTH,
Don
=============================
Use My*****@Telus.Net for e-mail
Disclaimer:
Professional PartsPerson
Amateur Database Programmer {:o)

I'm an Access97 user, so all posted code
samples are also Access97- based
unless otherwise noted.

Do Until SinksIn = True
File/Save, <slam fingers in desk drawer>
Loop

================================
Nov 13 '05 #6

P: n/a
Don,
Thanks!!
What you wrote - worked without a hitch, was simple for me to follow and
easily showed I can spend even more time on this simple form. :-) Now, as we
travel across the country I can just use a modification of the code you sent
to have a text box showing local time and race time - without having to
reset system time or computer time zone.
B.

Try this:

A form containing 2 textboxes:
txtCentral Time -- Control Source: =Now() -- Format: LongTime
txtLocalTime -- Control Source: Unbound -- Format: LongTime

Now add an option group ("optTimeZone") containing the 7 time zones, and add the code below to the form's On Timer event (Interval = 1000 ms)
Selecting a time zone from the option group will display the correct time
for that region in txtLocalTime.
********************************
Private Sub Form_Timer()

Select Case optTimeZone

Case 2 'Pacific
Me.txtLocalTime = DateAdd("h", -2, Now())
Case 3 'Mountain
Me.txtLocalTime = DateAdd("h", -1, Now())
Case 4 'Central
Me.txtLocalTime = Now()
Case 5 'Eastern
Me.txtLocalTime = DateAdd("h", 1, Now())
End Select

Me.Recalc

End Sub

Nov 13 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.