Please Help ! Time Calculations

tuisb3

Registered User.
Local time
Today, 16:11
Joined
Aug 1, 2013
Messages
14
HI,

I am a new member and have signed up as I need help with a specific task.

I have created a contacts database to hold various information about some of our company sites and locations. We have many locations dotted around worldwide. I have created the database exactly how I want it and it does everything I need it to.... apart from one thing!

I have a field on a form that holds information about the Timezone in which that site is located. This field is a drop down box with +12 through to -12. I want a label at the top of the form that calculates the current time, minus or plus the value in hours that the timezone box is set to. This will result in the current local time being displayed at the top of the form.

If anyone can help with the calculation that I should enter into the box that would be great. I am new to Access and this forum and am just trying to teach myself, so I really do apologise if this is something very simple or is a stupid question.

Many thanks for your help

Regards

Steve
 
try this
Dim newTime As Date
newTime = DateAdd("h", 12, Now()) 'adds 12 hours

or newTime = DateAdd("h", Forms!YourForm.YourTimezoneField, Now())

where Forms!YourForm.YourTimezoneField
You just need to set the value of the label to the variable newTime

You can set this code to fire either using the form's OnCurrent event or afterUpdate of the timezone drop down

David
 
DavidAtWork you are a genius! Thanks very much it worked a treat!

I can now set the timezone on a record and it displays the correct time for that office. You have made me a happy man and my database is complete! :)

Thanks so much!

Kind regards

Steve
 

Users who are viewing this thread

Back
Top Bottom