Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Nov 2004
    Location
    London, United Kingdom
    Posts
    152
    Thanks
    0
    Thanked 0 Times in 0 Posts

    code to run at a specific time (Access 2000)

    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

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

    Re: code to run at a specific time (Access 2000)

    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).

  3. #3
    2 Star Lounger
    Join Date
    Nov 2004
    Location
    London, United Kingdom
    Posts
    152
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: code to run at a specific time (Access 2000)

    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

Posting Permissions

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