Is it possible to schedule Access so it will run a query or report overnight.
If so how?
Thank you in advance.
colin_e - 12 Jan 2006 15:51 GMT
Caveat: I haven't actually done this myself yet ;-)
However, I think the approach I would probably take would be to use the
Windows Scheduler to run your Access application at the desired time. Then
set the command line options in the scheduler to run access in exclusive
(read only) mode, and with a command line parameter to initiate the VBA code
for your batch job.
Looking at the docs, it seems the /cmd command line switch is specifically
designed for this purpose. A startup script (VBA) in your database can use
the the Command function to return any parameters supplied after the /cmd
switch
e.g. something like:
<path to access> <database name> /excl /cmd please_run_my_code_now
Regards: Colin
> Is it possible to schedule Access so it will run a query or report overnight.
> If so how?
>
> Thank you in advance.
RobFMS - 12 Jan 2006 16:49 GMT
I do not have a code solution. However, I do have a recommendation for a
product you can purchase.
If you are interested, then please respond with such.

Signature
Rob Mastrostefano
FMS Professional Solutions Group
http://www.fmsinc.com/consulting
Software Tools for .NET, SQL Server, Visual Basic & Access
http://www.fmsinc.com
> Is it possible to schedule Access so it will run a query or report
> overnight.
> If so how?
>
> Thank you in advance.
Philip Szlyk - 12 Jan 2006 17:00 GMT
There are many ways to do this, but one way is perhaps the easiest:
1.) Create a table called "tblRunDate" with one field ("TodaysDate") as a
DATE type with the format m/d/yyyy.
2.) On a form "frmMainMenu" (which you will leave OPEN at night): Create a
command button on it in order to print that report manually, if you so choose.
Private Sub cmdPrint_Click()
'
'to check field "TodaysDate" in "tblRunDate"; if the date in that
'field NOT equal to today's actual date, then run the code below;
'if the the date in that field = today's actual date, then the code below
'has already been run today - so do NOT run it again
dim rs as Recordset
dim db as Database
set db = CurrentDB
Set rs = db.OpenRecordset("tblRunDate", dbOpenDynaset)
rs.MoveFirst
'if field has today's date, then do NOT run updates - already run today
If Format(rs![TodaysDate], "m/d/yyyy") = Format(Date, "m/d/yyyy") Then
'clean up, but do nothing else
rs.Close
Set rs = Nothing
Set db = Nothing
Exit Sub
ElseIf Format(rs![TodaysDate], "m/d/yyyy") <> Format(Date, "m/d/yyyy") Then
'need to run updates, since not run yet today
'first, update field to today's date
rs.Edit
rs![TodaysDate] = Format(Date, "m/d/yyyy")
rs.Update
'next print the Report you wanted to print
DoCmd.Hourglass True
DoCmd.Echo False, "Report running. Please wait..."
DoCmd.SetWarnings False
'To print report to printer
DoCmd.OpenReport "YourReport", acViewNormal
'To print your rteport to screen
DoCmd.OpenReport "YourReport", acViewPreview
DoCmd.Hourglass False
DoCmd.Echo True
DoCmd.SetWarnings True
'
End If
'End Sub
Also, put in code to capture errors, if you like.
3.) Now, on that form's ("frmMainMenu") , set the TIMER = 1800000 (30 mins)
(or whatever time length you want)
4.) In the ON TIMER event, call the "cmdClick_Print" Sub
Private Sub Form_Timer()
Call cmdPrint_Click()
End Sub
OR
Private Sub Form_Timer()
cmdPrint_Click
End Sub
That should do it!
Best of luck.
Phil Szlyk
> Is it possible to schedule Access so it will run a query or report overnight.
> If so how?
>
> Thank you in advance.
SteveG - 16 Jan 2006 20:36 GMT
Another possible solution might be to create a batch file that calls a VB
Script file. The VB Script file can invoke MS Access using the command line
argument /x to run a macro. Then add it as a scheduled task (look in the
Control Panel in Windows XP) that runs the program cmd.exe calling the batch
file.
If this is too cryptic, you need additional details or want an example
please post a reply and I'll provide details.
> Is it possible to schedule Access so it will run a query or report overnight.
> If so how?
>
> Thank you in advance.
MikeVB - 07 Mar 2006 22:31 GMT
Steve,
I am very intrigued by your posting. Would you be willing to provide
additional details or an example?
Thank you!
Mike
> Another possible solution might be to create a batch file that calls a VB
> Script file. The VB Script file can invoke MS Access using the command line
[quoted text clipped - 9 lines]
> >
> > Thank you in advance.
DonnaS - 07 Jun 2006 20:34 GMT
SteveG,
I am very interested in an example.
My MSAccess application/database will close down at the close of business
and we need e-mails sent out in the evening depending on the activity posted
in the database. Our current Lotus Notes application does this and the
customers are complaining about loosing this functionality when I convert the
system to MSAccess.
Thanks for any help you can provide.

Signature
DonnaS
> Another possible solution might be to create a batch file that calls a VB
> Script file. The VB Script file can invoke MS Access using the command line
[quoted text clipped - 9 lines]
> >
> > Thank you in advance.
RCB - 20 Jan 2006 16:10 GMT
Create a Macro to accomplish the required action or call function to run.
After creating Macro create a shortcut.
From Scheduled Tasks create task that calls Shortcut at desired time.
> Is it possible to schedule Access so it will run a query or report overnight.
> If so how?
>
> Thank you in advance.