' Using RDC components and Visual Basic
' Open the main report
' Then find the subreport and open it
' Logon to the subreport
Dim Report As CRAXDRT.Report
Dim SubReport As CRAXDRT.Report
Dim App As CRAXDRT.Application
Dim Sections As CRAXDRT.Sections
Dim Section As CRAXDRT.Section
Dim RepObjs As CRAXDRT.ReportObjects
Dim SubReportObj As CRAXDRT.SubreportObject
Dim n As Integer
Dim i As Integer
Dim j As Integer
Set App = New CRAXDRT.Application
Set Report = App.OpenReport("your.rpt")
For n = 1 To Report.Database.Tables.Count
Report.Database.Tables.SetLogOnInfo "server", "dbname", "user", "pass"
Next n
Set Sections = Report.Sections
For n = 1 To Sections.Count
Set Section = Sections.Item
Set RepObjs = Section.ReportObjects
For i = 1 To RepObjs.Count
If RepObjs.Item(i).Kind = crSubreportObject Then
Set SubReportObj = RepObjs.Item(i)
Set SubReport = SubReportObj.OpenSubreport
For j = 1 To SubReport.Database.Tables.Count
SubReport.Database.Tables(j).SetLogOnInfo "server", "db", "username", "pass"
Next j
End If
Next i
Next n
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.