Timer Event

Jonny45wakey

Member
Local time
Today, 21:25
Joined
May 4, 2020
Messages
48
Hi I would like the on-timer event of a hidden form to trigger

DoCmd.OpenForm "formnamehere"

every hour using the computer time, essentially if time (minutes) = 00 then run the docmd

How would this be formatted in VBA please?

Thanks

Jonny
 
All

I have sorted this through trial and error, on the hidden form is a textbox "txttime" with bounds to =Now()
and timer interval set to 60 seconds.

When the On Timer event fires the following code opens the second form (which is like a popup form)

Private Sub Form_Timer()
Me.Refresh
If Minute(Me.txtTime) = 0 Then
DoCmd.OpenForm "frmReminder"
End If
End Sub


Regards

Jonny
 
Just got back from my morning walk, so Pat beat me to it.

With programming (as with much else in life), everything has a purpose. If you pop open a form every hour, there is a question of purpose. You see, forms are generally "action" elements - you DO something with a form. So what is the purpose of opening this form at a specific time? What is your user supposed to do with it? Suppose that the user has to take a rest-room break... Is the form going to stay open until the user comes back? What if the user goes to lunch and happens to be gone 1 hour and 2 minutes - which means the form would open twice? Have you considered contingencies for a user who just minimizes the form because s/he is busy doing something else?

That might have seemed a bit rambling, but that's actually the point. If we have no idea of the context, we cannot give you good advice for what you want to do. We will ramble all over the place trying to decide how to help you do something that might actually be simple but might also turn into a project that is at the level of a Master's Thesis in computer science. So where is this going?

By the way, the more efficient way to do that timer is when it fires and you want to re-trigger it at a specific time, build a time-string to the time you want, then use a DateDiff( "s", Now(), <projected time> ) * 1000 to set the next timer interval.
 

Users who are viewing this thread

Back
Top Bottom