
Change database for crystal report at runtime
I've accomplished something similar using VB5 and the Crystal OCX:
'CrystalReport1 is an instance of the Crystal OCX.
CrystalReport1.DataFiles(0) = txtInputFile
CrystalReport1.DataFiles(1) = "d:\data.db"
CrystalReport1.DataFiles(2) = txtInputFile
' ORDER of the DataFiles is very important!
Note that the order of databases can be determined by going to "Set Location"
from the Database menu. Also, if your report has subreports things get a
little bit tricky. You have to open each subreport, and set it's DataFiles
property as well. For what I needed, I abandoned VB5 and wrote the
application in VC++ 4.2 using the Crystal MFC classes and DLLs.
Quote:
> Hi,
> I've used a crystal custom control in VB4 (16-bit). I've try to set the
> value of the datafile property for changing the database of the report at
> runtime, however it does not work.
> Does anybody knows how to change to another database for crystal report
> (3.0) during run time.