p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

  Return to Index  

crystal_reports thread: RE: ERROR in sub Report: server has not yet bee- n opened

Message #1 by "Tetu Janos" <jtetu@f...> on Fri, 14 Feb 2003 19:54:02
Hi there!

I passed a few hours, and now got the solution to open subreports.
(Thanks to crystal for the non-working samples and pdfs...)

My main report object is CRXReport, and this snippet set the connection 
info for all the subreports in it.

My code:

Dim subRpt As CRAXDRT.Report
        Dim subReport As CRAXDRT.SubreportObject
        Dim sect As CRAXDRT.Section
        Dim rptObject As Variant
        For Each sect In CRXReport.Sections
            For Each rptObject In sect.ReportObjects
                If rptObject.Kind = crSubreportObject Then
                    Set subReport = rptObject
                    'MsgBox "[" + subReport.SubreportName + "]", vbCritical
                    Set subRpt = CRXReport.OpenSubreport
                    For Each objTable In subRpt.Database.Tables
                        If DatabaseType = "ODBC" Then
                            objTable.Location = MergePrefix
                            Call objTable.SetLogOnInfo(DatabaseName, 
DatabaseName, DatabaseUserName, DatabaseUserPassword)
                        End If
                        If objTable.TestConnectivity = False Then
                            MsgBox "An error occured while setting the 
data source for the table:" + objTable.Name, vbOKOnly + vbExclamation, 
                            Exit Sub
                        End If
                    Next objTable
                    Set subReport = Nothing
                End If

-hope you'll find it usable..

  Return to Index