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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculate time zones 1

Status
Not open for further replies.

aw23

Programmer
Nov 26, 2003
544
IL
I have clients in countries all around the world. I want to load the local time for the client when standing on the record of that client. So I thought I'd record in a table the GMT offset and get the gmt time and add. However this will not work as different countries change their clocks on different dates. Is there any simple way to do this?

Thanks
 
I ran into that too when I left the form open and shut down my Internet connection. We post a lot of simplified examples here without error handling, but in production apps that's not how most of us deliver the code. I added an error handler to catch it and moved the update call to the Form_Timer() event to simplify it a bit:
Code:
Option Compare Database
Option Explicit

Private WithEvents mWorldTime As WorldTime

Private Sub Form_Current()
  Me!txtCurrentTime = ""
  Me.TimerInterval = 1000    [green]'1 second[/green]
End Sub

Private Sub Form_Load()
  Set mWorldTime = New WorldTime
End Sub

Private Sub Form_Timer()
On Error GoTo ErrHandler
  If Len(Me!City) > 0 Then
    mWorldTime.InitiateTimeStamp Me!City
    Me.TimerInterval = 15000   [green]'15 seconds[/green]
  End If
ExitHere:
  Exit Sub
ErrHandler:
  Select Case Err
    Case 91         [green]'Object not set - could be network lag.[/green]
      With Me.txtCurrentTime
        .Value = "please wait..."
      End With
    Case Else
      Debug.Print Err, Err.Description
  End Select
  Resume ExitHere
End Sub

Private Sub mWorldTime_TimeAcquired(ByVal strTime As String)
  If mWorldTime.City = Me!City Then
    Me.txtCurrentTime.Value = strTime
  End If
End Sub

I've trapped 1 other error within the class module that was thown by the SoapClient object when it couldn't connect to the service after it initialized, but the class module handles the error and ouputs the info to the debug window. If you want to do some further devlopment in that area, you can post your findings here so we all benefit from them.

For any app that I circulate, I always put error handlers in every routine as a matter of necessity, since my clients want to use the runtime version of Access and it will crash to Windows even with a simple unhandled error 91. Instead of printing errors to the debug window, I add an errors table and write every runtime error to the errors table including user name, a time stamp, the name of the form and event, and the err number and description. The call looks like this:
Code:
Call LogError("Form:" & Me.Name, "Form_Timer()", Err, Err.Description, "Optional string info")
The "LogError" routine takes the arguments passed in and adds the time stamp and user name to the errors table. Then I can check the table at my leisure to see what code is breaking, when it broke, and what idiot user broke it. [lol]


VBSlammer
redinvader3walking.gif

[sleeping]Unemployed in Houston, Texas
 
Thanks so much. That error table is a really good idea, I think I'll try that. I am not at work today but hopefully I will try it tomorow when I will be back.
 
Is it possible to do something similar with eschange rate? Let's say I have a db with several diff currencies and then every couple of minutes, or once a day, I run the code that gets the rate from the web service and populates the table. So when the user askes for the current rate, I just pull it from the table instead of live.
Is this possible? Sorry, I am trying to learn all this but it's a little beyond me to figure it out on my own at this point.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top