Form_Timer Event

J

Jac Tremblay

Hi,
In the Form_Load event, I set:
datStart = Now()
In the Form_Timer event, I have:
If (Now() - datStart) * 3600 > 5 Then

' Close the splash screen and open the main menu.
DoCmd.Close acForm, Me.Name, acSaveYes
DoCmd.OpenForm "frmMainMenu", acNormal
End If
I wander if that is correct if I want the splash screen to display 5
seconds. With that setting, it lasts about 2 minutes.
What should I change if I want it for 5 minutes or 5 seconds?
Thanks.
 
J

Jac Tremblay

Hi Mike,
I know that the Timer interval is in milliseconds. What I want to know is
the format of the time calculation result. I guess it is in decimal, which
means a decimal fraction of a day.
So the difference between two date/time values gives a fraction that one has
to convert in seconds or milliseconds (or whatever he needs).
Since there are 86400 seconds in a day (3600 * 24), I guess I could multiply
the result with that figure and compare it to 5000 milliseconds.
I will try that and reply later.
Thanks, you helped me think.
 
J

Jac Tremblay

Hi Mike,
I figured it out. Here is how one should code the If statement:
If (Now() - datStart) * 86400 > 5 Then
'...
That will fire after 5 seconds. If one wants 5 minutes, then he should write:
If (Now() - datStart) * 86400 > 300 Then ' That is: 5 min. * 60 sec. / min.
'...
The TimerInterval property can be set to 1000 (1 sec.), or 5000 (5 sec.), or
anything else as one wishes. That one is in milliseconds.
Thanks for your time.
That comment is for the posterity (I tried to find how to code the OnTimer
event for a while but could not find it. Next time, I will).
 

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