Solved

Run Access report after batch file has completed

Posted on 2013-05-21
6
449 Views
Last Modified: 2013-05-21
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.
0
Comment
Question by:printmedia
6 Comments
 
LVL 26

Expert Comment

by:pony10us
ID: 39185064
It sounds like a timing issue in the batch file.  Can you post the batch file?
0
 

Author Comment

by:printmedia
ID: 39185072
DTSRun /S "ServerName" /N "Copy Tables" /G "{CA005610-A55A-4209-8A3D-A4E99D844D67}" /W "0" /E 

if errorlevel 1 goto error
echo SUCCESSFUL!!!

PAUSE
goto end
:error
echo ERROR!!! 
PAUSE
:end

Open in new window

0
 
LVL 26

Expert Comment

by:pony10us
ID: 39185118
Where did you open the access report?  

If you are running Vista or newer then you can use the builtin timeout command. I would place it after the "echo SUCCESSFUL!!!" line and give it a delay of 1 minute to start with and disable keystrokes to break out of it. You can adjust the time by seconds until you get it figured out.

timeout /t 60 /nobreak
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

Author Comment

by:printmedia
ID: 39185164
As a I mentioned above, I tried using an Access macro that would open the batch file and then open the Access report.

The report is in an Access database that is on a shared folder on the server. So your suggestion is to have the batch file open the report?

What syntax? We are on Windows XP machines with Access 2003.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 39185177
How are you *actually* running the batch file?

Here is the way I would do this...
Put the Batch file in one sub, and the Open Report code in another:
Sub RunBatch()
    'Your code to run the batch here
End sub

Sub RunReport()
    'Your Open report code here
End sub

Then run them sequentially , like so:

Sub RunAll()
    Call RunBatch
    Call RunReport
End sub

JeffCoachman
0
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 39185181
Where in this process were you opening the Access Report?

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.exe" "C:\Users\firstname.lastname\Documents\Work\Access\Experts Exchange\OpenReport.accdb" /cmd "rpt_Numbers"

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
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question