Looping help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have 5 graphs all of which are in an active window, however I only want one
of them to update every ten seconds, the other 4 can update every minute.
Each graph sucks in about 6000 records each so I am trying to cut down on
unnecessary hits to the server and network traffic. I have simply put in the
OnTimer event the following...

Private Sub Form_Timer()
Dim Graph As Control

Set Graph = Me!graphAll
Graph.Requery

Set Graph = Me!graph1
Graph.Requery

Set Graph = Me!graph2
Graph.Requery

etc....

The "graphAll" needs to update every 10 seconds. The others every minute on
the whole minute. I am not sure where to start with this. Any help is
appreciated.
 
I think I'd try a "counter" to solve this problem.
Every time the GraphAll requeries, increment a variable (ex.
RequeryCounter - Integer) to 10,20,30... up to 60. At 60 requery the other
forms, and reset the counter to 0. (did not test this code, but it should
fly... tweak to suit)

Private Sub Form_Timer()
Dim Graph As Control
Dim RequeryCounter as Integer

Set Graph = Me!graphAll
Graph.Requery
RequeryCounter=RequeryCounter+10

If RequeryCounter = 60 Then
'refresh the other 3 graphs.....
RequeryCounter = 0
End If

hth
Al Camp
 
webster said:
I have 5 graphs all of which are in an active window, however I only
want one of them to update every ten seconds, the other 4 can update
every minute. Each graph sucks in about 6000 records each so I am
trying to cut down on unnecessary hits to the server and network
traffic. I have simply put in the OnTimer event the following...

Private Sub Form_Timer()
Dim Graph As Control

Set Graph = Me!graphAll
Graph.Requery

Set Graph = Me!graph1
Graph.Requery

Set Graph = Me!graph2
Graph.Requery

etc....

The "graphAll" needs to update every 10 seconds. The others every
minute on the whole minute. I am not sure where to start with this.
Any help is appreciated.

Set the TimerInterval to the smallest interval you need; in this case
10 seconds = 10000 milliseconds. Requery the "graphAll" graph every
time the Timer event fires, requery the others only every 6th time (for
once every 60 seconds).

'----- start of code -----
Private Sub Form_Timer()

Static lngCtr As Long

Me!graphAll.Requery

If lngCtr = 0 Then
Me!graph1.Requery
Me!graph2.Requery
Me!graph3.Requery
Me!graph4.Requery
End If

lngCtr = lngCtr + 1
If lngCtr > 5 Then
lngCtr = 0
End If

End Sub
'----- end of code -----
 
Back
Top