0

I'm looking to add a schedule task which will trigger a call to an MS Access Sub. Should I write a script or are there in built MS Access features which would facilitate the automatic invoking of the following sub.

I didnt work on VB before. I have checked this other question on stackoverflow. How to schedule a call to an MS Access macro?

But the question was about Macro. I tried running it but it didnt work. Sub I am trying to add to a schedule task.

Private Sub cmdArchive_Click()
    DoCmd.Hourglass True
    DoCmd.OpenQuery "qryArchive"
    setDBConst "last_archive", CStr(Now)
    DoCmd.Hourglass False
    MsgBox "Today's Events have been archived.", vbOKOnly, "Archive Complete"
End Sub
Community
  • 1
  • 1
Srujan Kumar Gulla
  • 5,721
  • 9
  • 48
  • 78
  • If you are building this directly in MS Access I am fairly certain that you will need to just add it into a form timer event. Either on your main form that is always open or a hidden form that is always open. – Newd Jan 16 '15 at 19:39
  • 1
    If you think you would prefer to use a Scheduled Task in Windows then you might be interested in my answer [here](http://stackoverflow.com/a/20251788/2144390). – Gord Thompson Jan 16 '15 at 20:12

1 Answers1

0

This is an example of my (slightly modified) "Home" Form_Timer. My timer runs every 60000ms. Generally I just do a check in each function to see if something "Should" run and run it. So you could call your archive function and check in there if the archive should be run. Just be aware that if you are on a multi-user environment you will need to adjust accordingly.

'============================================================================
' Form_Timer
'============================================================================
 Private Sub Form_Timer()

    Call CloseDatabase
    Call CheckForCPULock
    Call CheckTempErrorTable

End Sub
Newd
  • 2,174
  • 2
  • 17
  • 31