Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing database of a sub-report at runtime

Status
Not open for further replies.

mookie

Programmer
May 3, 2000
15
US
I am creating reports with VB6 and CR8 using RDC. These reports will be run at different locations with different database names. I have successfuly been able to change the database for the main report by using this code:

Const sDevDBName As String = "CSTS_Test_DB"
Dim sDBName As String ' Database name
Dim Report As New CrystalReport1 ' Crystal Report
Dim Table As Object


' Get the correct database name
sDBName = ReadINI("Database", "database", sINIFilePath)

'Set the correct database name
For Each Table In Report.Database.Tables
Table.Location = Replace(Table.Location, sDevDBName, sDBName)
Next


But now I have added a sub-report, I can't seem to access the database of the sub-report, any ideas?
 
Nevermind, I fixed the problem

using this code:

Dim CRXSubreportObj As CRAXDRT.SubreportObject
Dim CRXSubreport As CRAXDRT.Report


Set CRXSubreportObj = Report.Section5.ReportObjects.Item("Subreport1")
Set CRXSubreport = CRXSubreportObj.OpenSubreport
For Each Table In CRXSubreport.Database.Tables
Table.Location = Replace(Table.Location, sDevDBName, sDBName)
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top