Hi all.
I have a batch file that runs a SQL Server 2000 DTS. This DTS copies some tables that will be used in an Access report.
How can I go about opening the Access report AFTER the batch file has completed?
I tried using an Access macro, first I ran the batch file and the next step was to open the report but what would happen was the batch file would run and while it was running the access report was opened, this was causing incomplete data to appear on the report because the report was opening while the batch file was copying the tables. How can I fix this?
Thank you in advance.
I generally do this by creating a batch file, but since you already have one, you only need to add one line to it, which would look something like (inserted on or after line 5):
"C:\Program Files\Microsoft Office\Office12\msaccess.e
This string is broken up into 3 parts:
1. The path to your access application
2. The path to the database where the report exists (needs to be in Trusted Location)
3. the /CMD command followed by the name of the report
In the attached database, I have a simple table (10 records), a form (frm_Splash) and a report (rpt_Numbers).
frm_Splash is the startup form, and in the Form_Load event of that form, I have code to check and see whether a Command line parameter was passed to the application. If so, it accepts command line parameter as the name of the report and opens the report in preview mode (it will probably come up behind form). You can change that action to print the report instead of opening it in design view, or to output the report to a folder using the Docmd.OutPutTo command.
I have disabled the Application.Quit command, but whenever I open the application with a command line parameter, I quit the application when the desired action is complete.
The one other thing you will need to do is make sure that the database where the report resides is in a Trusted Location. Otherwise, the application will pause when the form is opened to allow you to acknowledge the Security Warning, click the Options button, and then "enable this content".
OpenReport.accdb