TimerInterval help

  • Thread starter Thread starter Chad
  • Start date Start date
C

Chad

Hello, Im having trouble figuring out what I need to do to have
"Me.LoggedOn.RowSource = WhosOn()" run every minutet or so. Im already using
the Timer Event for a progress bar that keeps running to show that its always
looking for new users. Could I possible put something in the forms current
event to run the "Me.LoggedOn.RowSource = WhosOn()" about every few minutes?
Would something like this work? Thanks!

Private Sub Form_Current()
If Me.TimerInterval = 1000 Then
Me.LoggedOn.RowSource = WhosOn()
End If
End Sub
 
A TimerInterval value of 1000 means one second. For one minute, use a value
of 60000. TimerInterval is measured in milliseconds (one-thousandth of a
second).
 
If I use this code in the on current event of the form will it consistantly
run every minute if I use the 10000? and will it effect the code im using in
the forms On Timer and Timer Intervals 300 for the other process im running?
 
The TimerInterval is going to be whatever you have it set to. so the line

If Me.TimerInterval = 1000 Then

Is useless. It isn't checking where in the timer cycle you are, only what the
Interval is set to. The Form_Current event runs whenever you move to a
different record. If the Interval is set to 1000, the code will run each time
you go to another record; if the intervals not set to 1000, it'll never run!


Code you want executed by the Timer Event has to reside in the Form_Timer
event. To execute multiple codes at different intervals, one has to be a
multiple of the other, i.e. one at 15 seconds and one at 30 seconds, or one
at 8 seconds and one at 24 seconds. Here's an example where, with the Timer
Interval set at 6000 (6 seconds) every 6 seconds a messagebox pops up with
the elapsed number of seconds, and on the 10th cycle (60 seconds) one form is
closed and another form opened.

Private Sub Form_Timer()
Static Counter As Integer

Counter = Counter + 1

MsgBox Counter * 6 & " Seconds" 'This will execute every 6 seconds

If Counter = 10 Then
DoCmd.OpenForm "Form2" ' this will open after 60 seconds.
DoCmd.Close acForm, "Form1" ' this will close after 60 seconds.
End If

End Sub

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
 
I have this code in the timer event. It just continusly runs 7 images to make
it look like a progress bar. The timer interval is set at 600. I just want to
run "Me.LoggedOn.RowSource = WhosOn()" so it would show me an updated list of
whos in the database. How would I incorperate this into my code below? Thanks!

Option Compare Database
Option Explicit
Dim bLoop As Byte

Private Sub Form_Timer()

If bLoop = 7 Then bLoop = 0
bLoop = bLoop + 1

If Not bLoop = 8 Then
If Me("img" & bLoop).Visible = False Then
Me("img" & bLoop).Visible = True
Else
Me("img" & bLoop).Visible = False
End If
End If
End Sub
 
How about running your WhosOn() function in the BeforeUpdate event of
your form? You don't need to keep interrogating it, only the value
at the time you save the record is important to you.,

HTH
 
Back
Top