Quote:
quote:Originally posted by Brendan Bartley
....get a report to run automatically in access database once a day.....
|
Option Compare Database
Option Explicit
' This code will run your report once a day, every day,
' at the specified time.
' Of cource, MSAccess and the form must remain open
' for the code to work 24/7.
'
Dim ReportRunDate As Date
' ReportRunDate will remember if your report has already been called today.
'
' In form properties, set can set timer interval to several seconds, no hurry.
Private Sub Form_Timer()
CheckMyScheduler
End Sub
Sub CheckMyScheduler()
Dim Ev1 As Integer
Ev1 = 21 ' set the hour at which the event should occur.
' has report already run today?
If Day(ReportRunDate) = Day(Now()) Then Exit Sub
If Hour(Now()) >= Ev1 Then
RunMyReport
End If
End Sub
'
Sub RunMyReport()
Beep ' insert code here to execute the report.
ReportRunDate = Now()
MsgBox "The report has done been runned"
End Sub