continual updating

  • Thread starter Thread starter dok112
  • Start date Start date
D

dok112

is there a way to have a caption update once every 1 minute? or every 5
minutes? My form is going to be keeping track of money that is being
spent, but I currently I have to click the update button when I want it
to update, where as if it auto-updates, it will save me some time...any
ideas???
 
The below code, place in a standard code module should do the trick.
Replace the line "RefreshMyCaption" with whatever your refresh procedure
is named.

HTH,
Gareth

Private Constant SyncFreqInMinutes as integer = 1
Private myOnTime As Date

Sub SetAutoUpdate
'cancel any outstanding events - just in case
'it's not strictly necessary.
CancelAutoUpdate 'just in case

'work out when you want the next update to take place
myOnTime = Now + Timeserial(0,1,0)

'set the next update to take place
Application.OnTime myOnTime , "SetAutoUpdate"

'rename as to whatever the procedure is to drive the
'refresh
RefreshMyCaption

End Sub

Sub CancelAutoUpdate()
On Error Resume Next
Application.OnTime EarliestTime:=myOnTime , _
Procedure:="SetAutoUpdate", _
Schedule:=False
End Sub
 
You're welcome - thanks for letting me know.

Note that I just spotted I should have written:

'work out when you want the next update to take place
myOnTime = Now + Timeserial(0,SyncFreqInMinutes ,0)

rather than

'work out when you want the next update to take place
myOnTime = Now + Timeserial(0,1,0)

Of course it will still work the same - since SyncFreqInMinutes was set
as 1 anyway - but it you want to change the frequency to 2 or 3 minutes,
say, you just change the constant SyncFreqInMinutes to 2 or 3 etc. And
of course you could always change it to work with seconds.

G
 

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

Back
Top