Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refreshing Crystal DB locations

Status
Not open for further replies.

OzWolf

Programmer
May 22, 2002
52
AU
Greetings,

I've run into a bit of a problem. A VB application I'm working on needs to be distributed to a number of different PC's and it will invariably be installed on various drives in differing directories.

The application also contains four Crystal reports. What we need the application to do is set the four Crystal RPT file's table locations to the local Access database when the application starts.

I've tried a number of different ways to get Report.rpt to save with the new locations to no luck. One method I tried was opening the Report.rpt file as a CRAXDRT report, setting the table locations, saving it as Report New.rpt, clearing the CRAXDRT object, killing the Report.rpt file and renaming the Report New.rpt file to Report.rpt. Unfortunately, it appears the CRAXDRT object places a lock on the Report.rpt file and won't allow its deletion.

So, I tried another method by renaming the Report.rpt file to Report Old.rpt then opening it as a CRAXDRT object, setting the table locations then saving it as Report.rpt. The Report Old.rpt file will either be killed when the application closes or at the next startup. Unfortunately, I keep receiving an inexplicable error message of File Already Exists. This occurs after it has renamed Report.rpt to Report Old.rpt and recreated Report.rpt (so the new file exists) and the module that ran the process has been closed. I cannot find what is causing the error to appear or why.

I'd greatly appreciate any solution somebody might have or a reason as to why I keep receiving the above error message. This is getting extremely frustrating.

Cheers,

OzWolf
 
There are a number of ways to control the locations of tables come runtime. Perhaps the simplest is to set up an ODBC DSN on each PC (say CrystalAccess), and have this DSN refer to the local Access database table. Your Crystal Report then accesses the DSN rather than the Access table directly.
A second and more complex method is to specify a new table location at runtime. Load the report as usual, then before running set the tables location. The Crystal Developer's help gives some samples ("Sample Code - Database Table Object", "Sample Code - SetLogOnInfo Method"). [yinyang]
 
Ok, I came back to the problem with a fresh frame of mind and found the problem instantly...I had an UNLOAD command before the module had finished its code. My laughter was tinged with just a hint of insanity ;)

Anyway, I have gone for option two: renaming the original files, opening them, setting the correct table locations then saving them as the correct file names then deleting the old files upon exiting the application.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top