change of database in a report with subreports 
Author Message
 change of database in a report with subreports

Hello,

I create an CrystalReport 'report1.rpt', which includes
the subreport 'report1a.rpt'. The database connection is
to MS-SQL-Server.

Now I want to run this report on an other computer ,
only with the runtime-files from CrystalReport.
The name of the database is different to my database.

I work with the OCX-Control,
Crystal Report 7.0.

With 'RetrieveDataFiles' I get the number of the tables in
the main-report.
With 'Datafiles (i)' I get the tables of the main-report.
I also get the subreports, with 'GetNSubreport()' and
'GetNthSubreportName()'.

But after I set the subreportName to 'SubreportToChange'
- > I don't get the 'Datafiles(i)' of the subreport.
And when I call 'RetriveDataFiles' once more, I get the Datafiles(i) of
the main-report.

How it works, change the database of a report with subreport ?



Mon, 14 Jul 2003 21:39:18 GMT  
 change of database in a report with subreports
We ran into same problem and therefore had to abandon
ActiveX and use CRPE. Pros: CRPE does not hold an RPT
locked; one less file to include into install package; more
functionality, less bugs. Cons: a little more typing overhead
to do the same things.

In CRPE, it would be like this:

Dim crpTable As crpeauto.DatabaseTable
Dim crpParameterField As crpeauto.ParameterFieldDefinition
Dim i As Integer

Dim crpSection As crpeauto.Section
Dim crpObjects As crpeauto.ReportObjects
Dim crpSubreport As crpeauto.Report

Set crpReport = crpApp.OpenReport("h:\deniss\cr2.rpt", 1)

'replacing head report locations
For Each crpTable In crpReport.Database.Tables
  crpTable.SetLogOnInfo "ACCESS", txtNewDataBase.Text, txtUserName.Text,
txtPassword.Text
  crpTable.Location = txtNewDataBase.Text & Mid(crpTable.Location,
InStr(crpTable.Location, "."))
Next crpTable

'looking up subreports...
For Each crpSection In crpReport.Sections
    Set crpObjects = crpSection.ReportObjects
    For i = 1 To crpSection.ReportObjects.Count
      If crpObjects(i).Kind = crSubreportObject Then
        ' ...and replacing locations
        Set crpSubreport = crpReport.OpenSubreport(crpObjects(i).Name)
        For Each crpTable In crpSubreport.Database.Tables
            crpTable.SetLogOnInfo "", txtNewDataBase.Text,
txtNewUserName.Text, txtPassword.Text
            crpTable.Location = txtNewDataBase.Text & Mid(crpTable.Location,
InStr(crpTable.Location, "."))
        Next crpTable
      End If
    Next
Next

crpReport.ParameterPromptingEnabled = False
crpReport.Preview , , , , , WS_VISIBLE + WS_CAPTION + WS_BORDER + WS_SYSMENU
+
WS_THICKFRAME + WS_MINIMIZEBOX + WS_MAXIMIZEBOX

Set crpReport = Nothing

--
Deniss Andrijevski
SKRIINING

Quote:
> Hello,

> I create an CrystalReport 'report1.rpt', which includes
> the subreport 'report1a.rpt'. The database connection is
> to MS-SQL-Server.

> Now I want to run this report on an other computer ,
> only with the runtime-files from CrystalReport.
> The name of the database is different to my database.

> I work with the OCX-Control,
> Crystal Report 7.0.



Tue, 15 Jul 2003 17:16:35 GMT  
 change of database in a report with subreports
I try it again with the OCX-Control.

If the mainreport and the subreport have the same datatables in the same
order,
it is possible to change the database with:
- SubReporttToChange and
- Datafiles(i).

Thanks a lot

So long Frank Iversen



Quote:
> We ran into same problem and therefore had to abandon
> ActiveX and use CRPE. Pros: CRPE does not hold an RPT
> locked; one less file to include into install package; more
> functionality, less bugs. Cons: a little more typing overhead
> to do the same things.

> In CRPE, it would be like this:

> Dim crpTable As crpeauto.DatabaseTable
> Dim crpParameterField As crpeauto.ParameterFieldDefinition
> Dim i As Integer

> Dim crpSection As crpeauto.Section
> Dim crpObjects As crpeauto.ReportObjects
> Dim crpSubreport As crpeauto.Report

> Set crpReport = crpApp.OpenReport("h:\deniss\cr2.rpt", 1)

> 'replacing head report locations
> For Each crpTable In crpReport.Database.Tables
>   crpTable.SetLogOnInfo "ACCESS", txtNewDataBase.Text, txtUserName.Text,
> txtPassword.Text
>   crpTable.Location = txtNewDataBase.Text & Mid(crpTable.Location,
> InStr(crpTable.Location, "."))
> Next crpTable

> 'looking up subreports...
> For Each crpSection In crpReport.Sections
>     Set crpObjects = crpSection.ReportObjects
>     For i = 1 To crpSection.ReportObjects.Count
>       If crpObjects(i).Kind = crSubreportObject Then
>         ' ...and replacing locations
>         Set crpSubreport = crpReport.OpenSubreport(crpObjects(i).Name)
>         For Each crpTable In crpSubreport.Database.Tables
>             crpTable.SetLogOnInfo "", txtNewDataBase.Text,
> txtNewUserName.Text, txtPassword.Text
>             crpTable.Location = txtNewDataBase.Text &

Mid(crpTable.Location,

- Show quoted text -

Quote:
> InStr(crpTable.Location, "."))
>         Next crpTable
>       End If
>     Next
> Next

> crpReport.ParameterPromptingEnabled = False
> crpReport.Preview , , , , , WS_VISIBLE + WS_CAPTION + WS_BORDER +
WS_SYSMENU
> +
> WS_THICKFRAME + WS_MINIMIZEBOX + WS_MAXIMIZEBOX

> Set crpReport = Nothing

> --
> Deniss Andrijevski
> SKRIINING


> > Hello,

> > I create an CrystalReport 'report1.rpt', which includes
> > the subreport 'report1a.rpt'. The database connection is
> > to MS-SQL-Server.

> > Now I want to run this report on an other computer ,
> > only with the runtime-files from CrystalReport.
> > The name of the database is different to my database.

> > I work with the OCX-Control,
> > Crystal Report 7.0.



Tue, 22 Jul 2003 00:56:09 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. vb5 Crystal Reports 6 and Subreports Can we conditionally call subreports from primary reports

2. changing databases in odbc doesnt change database in report

3. Changing a report that uses 1 database into a report using 2 databases

4. Crystal report - Change SubReport Location

5. Subreport design changes not reflected in main reports?

6. Reports with changed subreports

7. Change Database Location in Subreports

8. Crystal reports subreport in a subreport

9. Data Environment / Data Report / Changing database file at run time

10. Crystal Reports GPF after changing database structure

11. Changing Database with Crystal Reports 2.0

12. Crystal Report Database-Change

 

 
Powered by phpBB® Forum Software