Results 1 to 4 of 4

Thread: Automation (2k)

  1. #1
    5 Star Lounger
    Join Date
    Jul 2004
    Location
    Ohio
    Posts
    629
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Automation (2k)

    I have 5 or so macros for my database, and I want them to be run daily at 8am. They mail reports and what not to people using it.

    Is there a way to make access do this? or would it require outside programming (VB).
    <img src=/w3timages/blueline.gif width=33% height=2>
    <big>John</big>

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Automation (2k)

    The answer depends on whether the application runs constantly. If it does, you can use a form timer to periodically test to see if it is time to run the macros. If it is closed, you would have to use a batch file or a scheduler to launch the application with a command argument to trigger the operations.
    Charlotte

  3. #3
    5 Star Lounger
    Join Date
    Jul 2004
    Location
    Ohio
    Posts
    629
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Automation (2k)

    thats what i figured the answer would be. but you mentioning the schedular brings up a good point. i could use a scheduler to run the path & /xMastermacro to run my other macros, i think.

    thanks!
    <img src=/w3timages/blueline.gif width=33% height=2>
    <big>John</big>

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Automation (2k)

    You can use the On Timer event of a form. This requires that a) the database is open all the time and [img]/forums/images/smilies/cool.gif[/img] the form is open all the time (hidden, if you prefer).

    You must set the Timer Interval property of the form to a number of milliseconds, for example to check every 5 minutes, set Timer Interval to 5 * 60 * 1000 = 300000. If you set Timer Interval to 0, you effectively turn off the timer.

    In the event procedure for the On Timer event, you can check the current time, and if it is 8 am or just past it, run the macros. You must also do something to avoid the macros being run again the next time the On Timer event occurs on the same day. You could, for example, create a table tblMacroRun with one date/time field DateRun. Create one record in this table, and set the date field initially to today's date. The On Timer event could look like this:

    Private Sub Form_Timer()
    ' Error handling on.
    On Error GoTo ErrHandler

    ' Check if macros were last run before today.
    If DLookup("DateRun", "tblMacroRun") < Date Then
    ' Check if it's been 8 AM
    If Time > #8:00 AM# Then
    ' Insert code to run macros here.
    ...
    ' Set the date in the table to avoid further execution today.
    CurrentDb.Execute "UPDATE tblMacroRun SET DateRun = Date()"
    End If
    End If

    ' And get out.
    Exit Sub

    ErrHandler:
    ' You probably don't want to display error message.
    ' You could write something in a log table here.
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •