• code to run at a specific time (Access 2000)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » code to run at a specific time (Access 2000)

    • This topic has 2 replies, 2 voices, and was last updated 20 years ago.
    Author
    Topic
    #418750

    I was wondering if there is anything like Application.Ontime (in excel) where I can set my code to run at a specific time each evening?

    Many thanks

    Amanda

    Viewing 0 reply threads
    Author
    Replies
    • #943458

      Access does not have the equivalent of Application.OnTime, but a form has an On Timer event and a Timer Interval property. If Timer Interval is > 0, the On Timer event will fire every (Timer Interval) milliseconds. So for example if you set Timer Interval to 3600000 the On Timer event will fire every hour (3,600,000 = 60 x 60 x 1,000), and if you set it to 86400000 it will fire once a day (86,400,000 = 24 x 60 x 60 x 1,000). You can call the code you want to run from the event procedure:

      Private Sub Form_Timer()
      Call MyCode
      End Sub

      where MyCode is the name of the procedure (or function) you want to run. A prerequisite is that the database remains open, and the form within the database too.

      Alternatively, you can use a Scheduler Utility to open the database at a specific time, and let it run code automatically (through a startup form or an AutoExec macro).

      • #943945

        Hans,

        Many thanks for this. I was going to use the scheduler, but I don’t really want the code to run each time I need to access the database.

        Therefore I will stick to the On Timer event and a timer interval. I want the code to run at about 5 am each morning. Rather than go into the office at this time (I’m not great in the mornings). I will get a form to open the form with the On timer event and set it at 5 am for 86400000 so that it will run from then on at 5 am.

        Thanks for your help. As always much appreciated.

        Amanda

    Viewing 0 reply threads
    Reply To: code to run at a specific time (Access 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: