printmedia
asked on
Run a batch file when a Crystal Report is opened
Hi all.
We have a Crystal Report (v. 2011) that when opened we would like it to run a batch file. This batch file will refresh the tables used in the Crystal Report. The batch file copies new data from our ERP software database into the tables the Crystal Report uses. The thing is that the Crystal Report can be run at any time so therefore we need to refresh the tables everytime it is run.
Any idea if I can do this? If not, I'll probably have to create a form in Visual Studio with a button so when the end user clicks the "Run Report" button it will first run the batch file and then open the Crystal Report.
Any other suggestions?
Thank you in advance.
We have a Crystal Report (v. 2011) that when opened we would like it to run a batch file. This batch file will refresh the tables used in the Crystal Report. The batch file copies new data from our ERP software database into the tables the Crystal Report uses. The thing is that the Crystal Report can be run at any time so therefore we need to refresh the tables everytime it is run.
Any idea if I can do this? If not, I'll probably have to create a form in Visual Studio with a button so when the end user clicks the "Run Report" button it will first run the batch file and then open the Crystal Report.
Any other suggestions?
Thank you in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I'd agree with James that you should put this refresh code in a stored procedure and then call this SP as the data source in the report. We've done this successfully in the past.
An alternative to Before_Report_Run_SQL option mentioned by mlmcc above is to create or get a User Function Library that provides a function to call a batch file.
You can see a list of 3rd-party UFLs here and at least some of them provide such a function.
The Crystal formula calling the function would need to start with a BeforeReadingRecords; directive to ensure the call executes before the report retrieves the records.
You can see a list of 3rd-party UFLs here and at least some of them provide such a function.
The Crystal formula calling the function would need to start with a BeforeReadingRecords; directive to ensure the call executes before the report retrieves the records.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It does appear that the Crystal utilities that Ido Millet has developed has that capability
Visual Cut
http://www.milletsoftware.com/index.htm
Visual Cut User Manual
http://www.milletsoftware.com/Visual_CUT_User_Manual/#Table%20of%20Command%20Line%20Arguments
His Update a Database Before Report Runs (Before_Report_Run_SQL) seems to be able to do what you want
mlmcc