Alla2552

I have Visual Basic 2005 windows application that is connected to Access 2003 database and has multiple Crystal reports (ver 10.2.3600.0). I can preview all reports without problem. But when I preview report, save it to specific location (saving data as Word report) and then try to open any other report - getting Load report failed error. It seems like it's switching location of the reports to the location of the report I just saved and can't find my other crystal reports. How can I return it back to the location that all my reports are located to

Part of the code:

crReportDoc.Load(rptname)

strSelect = ""

For Each MyTable In crReportDoc.Database.Tables

MyLogin = MyTable.LogOnInfo

MyLogin.ConnectionInfo.ServerName = fileloc

MyLogin.ConnectionInfo.DatabaseName = fileloc

MyTable.ApplyLogOnInfo(MyLogin)

Next

CrystalReportViewer1.ReportSource = crReportDoc

'set strSelect here to the specific condition for each report

CrystalReportViewer1.SelectionFormula = strSelect

CrystalReportViewer1.RefreshReport()

After saving the data and trying to open different report (using the same code, same CrystalReportViewer) - I get an error on the first line crReportDoc.Load(rptname). Please help! Thanks, Alla



Re: Crystal Reports for Visual Studio Load report error - after saving report to disk

Manish Joisar

rptname - here you have given full path






Re: Crystal Reports for Visual Studio Load report error - after saving report to disk

Alla2552

No - I just give it a name of the report. I'm running application on multiple servers - so it picks it up automatically. Is there another way to specify the path - so it'll work for any server I distribute reports in the same folder with exe file - same folder name on all servers. The database that crystal gets data from - is located on the shared drive. Thanks, Alla





Re: Crystal Reports for Visual Studio Load report error - after saving report to disk

Joe Beam


The problem is that after saving a report your current working directory gets changed to that folder. You can store your application directory in a global variable. Then when setting the report path use...

crReportDoc.Load(appPath & rptname)







Re: Crystal Reports for Visual Studio Load report error - after saving report to disk

Alla2552

Thanks. I figured that the problem is with the path but I don't know how to change it - since I wouldn't know which server user will be on - while saving the report (so application path is slightly different for each user/group of users). Is there any command that would give me the path for any user/any server I appreciate your help!





Re: Crystal Reports for Visual Studio Load report error - after saving report to disk

Joe Beam

This property...

System.Environment.CurrentDirectory

will be the path to the application directory (when your program starts). Be sure to save it in a global variable so it's not lost after saving a report.




Re: Crystal Reports for Visual Studio Load report error - after saving report to disk

Alla2552

Thank you so much! I was hoping that it would be something simple - but didn't know command! Thanks again, Alla





Re: Crystal Reports for Visual Studio Load report error - after saving report to disk

Joe Beam


You could also use...

Application.StartupPath()

and then you wouldn't need the global variable. Sorry I forgot about this one.