
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.