
Crystal Report: DB Path manipulation in VB code
Hi everybody,
How do I change the DB path for the tables of a Crystal Report using
DataFiles property of Crystal control in a GENERIC PIECE OF CODE', using
a FOR loop? Or put it that way: how do I get the numbers of tables that
are used in a Crystal Report (needed for my FOR loop)?
Read my thoughts to this below:
In Crystal Reports full path names to the DB have to be indicated for
every table used in the report (ugly, ugly, such things need to be
parameterized using INI-files). This is made at design time of the
report, and so the DB directory at installation time of the software
will be probably different. I understand that I can change the DB
directory using the DataFiles property of the crystal control. The
directory for every table has to be changed separately, writing one line
of code per table used.
I want to write generic code for most of the repeated processes of a
crystal control on a VB form (I work with dozens of reports and do not
want to repeat the code for every crystal control). The problem is that
I do not know at design time how many tables there are in one report, so
I cannot put the directory assignment in a for loop. I do not see any
property that tells me what is the max index for the DataFiles property.
The FOR loop would be like that:
for i = 1 to maxTables
rptReport.DataFiles(i) = <DB path>
next
(DB path is a variable in my app INI file)
So where do I get the value of maxTables from? This loop has to be
executed before every print of the report. That is quite disturbing. Is
there really no other choice to do it?
It seems to me that Crystal Reports is lacking some parameterization.
Full path usage at design time is an ugly thing to do (normally you let
the user choose to which directory he wants to installo software), that
is why INI-files are existing. Only, how do I get Crystal Reports to
read my INI-file, nor does the component have an own INI-file. It is not
possible, apparently. I actually do not understand what the developers
of the Crystal Report component were thinking, writing that piece of the
software. At least they could have provided a crystal control property
that provides the number of tables used in the report.
Any suggestions or help very welcome
Thomas