Solved

Run Access report after batch file has completed

Posted on 2013-05-21
6
468 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

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 48

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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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.

696 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