automate macro every 30 minutes

  • Thread starter jack gunawan via AccessMonster.com
  • Start date
J

jack gunawan via AccessMonster.com

Hi, I need help. How can I automate macro every 30 minutes without manually
running the macro so as to backup my tables. Thanks for the kind attention.



Jack
 
G

Guest

I don't have a lot of time to explain. But look at the timer interval and
timer events in a form.

I create an unbound control on a form and Name it "Ttime". This example uses
a one second timerinterval and I use the if statements to execute different
code at different times. There are unlimited uses of these timer things.

I add two macro buttons. One Start and the other End

Private Sub Start_Click()
'Start
Me.TimerInterval = 1000 ' or one second
Me.TTime = 1

End Sub

Private Sub End_Click()
'End
Me.TimerInterval = 0 ' No timeer
Me.TTime = 1
End Sub



Private Sub Form_Timer()

If Me.TTime = 2 Then

Call C03_Click

ElseIf Me.TTime = 7 Then
Call C04_Click
ElseIf Me.TTime = 12 Then
Call C05_Click
ElseIf Me.TTime = 17 Then
Call C06_Click
ElseIf Me.TTime = 22 Then
Call C07_Click
ElseIf Me.TTime = 60 Then


DoCmd.RunCommand acCmdRecordsGoToNext 'This advances the form to
the next recrod.

ElseIf Me.TTime >= 65 Then
Me.TTime = 0 'This is how I loop the macro.
Me.TimerInterval = 0 'Stops the execution I'm in a debugging mode and
only want this to run once
End If
Me.TTime = Me.TTime + 1 'This adds one to Ttime eaach second. When you
reach 66 it is set back to 0. In this way my macro is looping through all the
records in my database. If you want to be good you will detect the end record
and stop your execution. At the end of your database it will error out in
most cases.


End Sub

Microsoft Help
TimerInterval Property
See AlsoApplies ToExampleSpecificsYou can use the TimerInterval property to
specify the interval, in milliseconds, between Timer events on a form.
Read/write Long.

expression.TimerInterval
expression Required. An expression that returns one of the objects in the
Applies To list.

Remarks
The TimerInterval property setting is a Long Integer value between 0 and
2,147,483,647.

You can set this property by using the form's property sheet, a macro, or
Visual Basic.


Note When using Visual Basic, you set the TimerInterval property in the
form's Load event.


To run Visual Basic code at intervals specified by the TimerInterval
property, put the code in the form's Timer event procedure. For example, to
requery records every 30 seconds, put the code to requery the records in the
form's Timer event procedure, and then set the TimerInterval property to
30000.

Example
The following example shows how to create a flashing button on a form by
displaying and hiding an icon on the button. The form's Load event procedure
sets the form's TimerInterval property to 1000 so the icon display is toggled
once every second.

Sub Form_Load()
Me.TimerInterval = 1000
End Sub

Sub Form_Timer()
Static intShowPicture As Integer
If intShowPicture Then
' Show icon.
Me!btnPicture.Picture = "C:\Icons\Flash.ico"
Else
' Don't show icon.
Me!btnPicture.Picture = ""
End If
intShowPicture = Not intShowPicture
End Sub
 

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

Top