Refresh code after every 10 seconds automatically

aman

Registered User.
Local time
Today, 15:18
Joined
Oct 16, 2008
Messages
1,251
Hi Guys

Please see below the code. I want to call commandbutton1,2,3 after every 10 seconds automatically but following code doesn't do that. Any help would be much appreciated.
Code:
Private Sub UserForm_Initialize()
'Update the Barcodes printed today
        Call CommandButton1_Click
        'Update batches to be scanned / batches scanned today
        Call CommandButton3_Click
        'Update files batched and counted today
        Call CommandButton2_Click
Application.OnTime Now + TimeValue("00:00:00"), "GoToSub"
      End Sub
 
Sub GoToSub()
'Update the Barcodes printed today
        
Call CommandButton1_Click
        'Update batches to be scanned / batches scanned today
        Call CommandButton3_Click
        'Update files batched and counted today
        Call CommandButton2_Click
        
        Application.OnTime Now + TimeValue("00:00:05"), "GoToSub"
End Sub
 
If you are trying to run code repeatedly just use the OnTimer event on the form.
 
I have used OnTime event as you can see in the code but it doesn't refresh .
 
That's not what I meant - There is an OnTimer event associated with the form There is no Application.OnTime event in Access VBA this is an Excel call.

In the form design look at the form properties - On Timer and Timer.
Attach your command button calling code to the Private Sub Form_Timer() event.
Set the form Timer to 10000 for 10 seconds.
 
Thanks Minty, Can you please help me with the code?
 
You already have it in your original code.

Code:
Private Sub Form_Timer()

Call CommandButton3_Click
Call CommandButton2_Click

End Sub

This will fire as often as the you have set the timer value to as long as the form is open.

To be honest if you are having to refresh this that frequently, I would suspect there is a more efficient way to achieve what you need, but we haven't seen the whole process.
 
Minty, I think you are talking about Timer in Access?? sorry but I am writing code in Excel/VBA and there is Timer property.
 
This would be better off in the Excel forum then - and I wouldn't be trying to help you with Access, which I mentioned in post #4
 

Users who are viewing this thread

Back
Top Bottom