?
Solved

Run Access report after batch file has completed

Posted on 2013-05-21
6
Medium Priority
?
476 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
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 

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 earned 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

762 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