I need to automatically email reports from Access at a specific time
I really don't have a lot of experience creating macros in Access, but I tried creating a macro that will automatically send an email at a specific time. This is what it looks like so far:
if [time] = "12:00:00 AM" then
emaildatabaseobject
Object Type Report
Object Name NameofReport
Output Format PDF
To desiredemail@email.com
CC
BCC
Subject test
I would personally suggest using the MS Access Macro to solely perform the emailing operation (either using the
EmailDatabaseObject
action,SendObject
method of theDoCmd
object in VBA, or by automating the installed email client using ActiveX in VBA).You can then use Windows Task Scheduler to invoke the MS Access Macro at a given time or on a given schedule.
To create a Scheduled Task to invoke an MS Access Macro, perform the following steps:
taskschd.msc
MSACCESS.exe
executable.In the Add arguments edit box, specify the filepath to your database (enclosed in double quotes if the path contains any spaces), followed by the
/x
command-line switch and the name of your macro, e.g.:Or, if you have a SubMacro within the Macro:
You can find out more about the available command-line switches for MS Access here.