mailing daily report with schedule

  • Thread starter Thread starter Gavaruus
  • Start date Start date
G

Gavaruus

Hi all,

my task is to create a report as pdf that is automatically mailed
every day to several people.
So the following steps are necessary:

1) Create a scheduled task in the control panel that calls... --->
OK

2) a .bat file with a line like this: "C:\Program Files\Microsoft
Office\Office12\msaccess.exe" mydb.mdb /X SendDailyReport --->
OK

3) The macro SendDailyReport calls with the Action RunCode a Sub in a
form that is opened on startup ---> failed, because I am not so
familiar with VBA. How does the syntax look like to call a sub from a
specific form?

4) Running some queries and code. ---> partly failed
Problems with this code:
timeAndDay = timeTo + dayReport

Whereas:
timeTo has type Medium Time
dayReport type Short Date
timeAndDay is type General Date

This code works fine if I call it on the event "Before Update", but
when I call it in my Sub, then I get a "data type mismatch". I don't
understand the logic.

5) A mail is of the report is sent using DoCmd.SendObject ---->
partly failed, because I get the Outlook pop up "
A program is trying to send an e-mail message on your behalf. If this
is unexpected, click Deny and verify your antivirus software is up-to-
date.". Since I do not use exchange server, it requires me to write a
COM add-in OR using the CDO library with some additional code to work
around the problem. ( From: http://support.microsoft.com/default.aspx?scid=kb;en-us;263084
)
Or are there any other suggestions?

5) Quit MS Access using macro ----> OK

So if you have any suggestions for step 3,4 and 5, it would help me a
lot!

Thanks in advance,
Gavaruus
 
To Step 3)
I got it working with:
[Forms]![Main_Menu].[MailReport_Click]

PLUS switching off the sandbox mode in the registry:
\Software\Microsoft\Office\12.0\Access Connectivity Engine\Engines
\SandBoxMode = 2 (instead 3)

PLUS enabling all macros in the Trust center (I know, bad thing)

BUT:
It seems that the macro runs the action again an again, when it is not
completed within about 1 second (I have to click Accept of step 5,
this takes a bit). Is this behavior intended?

Gavaruus
 
Back
Top