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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I use SetLogonInfo to logon to the subreport when the subreport might be on a different database

Opening Subreport and Logon

How do I use SetLogonInfo to logon to the subreport when the subreport might be on a different database

by  balves  Posted    (Edited  )
' 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(n).SetLogOnInfo "server", "dbname", "user", "pass"
Next n

Set Sections = Report.Sections
For n = 1 To Sections.Count
Set Section = Sections.Item(n)
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
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top