Post Author: Pat Boba
CA Forum: General
First off, let me apologize. I'm a little cranky at the moment from the frustration of not being able to find a solution to activate this.
I have already created a Main Report that has 4 SubReport sections:
Rpt_067.rpt (This is the main)
Rpt_067 - AlsoServed.rpt
Rpt_067 - Events.rpt
Rpt_067 - Phones.rpt
Rpt_067 - ServesOn.rpt
We have almost 70 reports for this application, that use a general or global routine to display the CRViewer. This is the first time we have attempted to attach a report that contains Sub Reports.
The CRViewer properly displays the Main Report, with empty Sub Reports. In other words, non of the Sub Reports contain the data that is there. Naturally, Previewing the report in Crystal Reports properly displays all of the data correctly.
All samples for the CRViewer only show how to attach 1 Query to 1 Report. The documentation is sort of lacking the sample for simply attaching pre-existing Sub Reports to a Main Report, and successfully viewing it.
I assume that after the effort of properly attaching and linking all of the Reports and Queries in the RPT files, I must now turn around the do the same in my VB Application. That's fine, but HOW?? I'm not INSERTING a Sub Report. I'm not creating tables or queries on the fly. I'm simply trying to define to CR the Queries and then invoke the CRViewer.
Any help is very appreciated, so I will thank you in advance.
Request clarification before answering.
Post Author: wapper
CA Forum: General
If you are using RDC, you will probably find the solution in Knowledge Base article C2002360.
Each subreport needs to be set to proper database location before the data can be displayed. Also, logon credentials must be supplied, otherwise the subreports will not be able to display the data.
We use the following code to set up each report before actually running it (our data comes from MSSQL server):
Dim dbDatabase As Database Dim dbTemp As DatabaseTable Dim strTemp As String, lngIndex As Long Dim subReport As Report, subReportObject As subReportObject
If m_Report Is Nothing Then Exit Function For Each dbTemp In m_Report.Database.Tables dbTemp.SetLogOnInfo ServerName, DB_Name, UserName, Password lngIndex = 0 lngIndex = InStr(1, dbTemp.Location, ".") If lngIndex <> Empty Then '//if there is no "." then it may be SP, no need to substitute lngIndex = InStr(lngIndex + 1, dbTemp.Location, ".") dbTemp.Location = DB_Name & ".dbo." & Mid(dbTemp.Location, lngIndex + 1) End If Next '//update possible subreports Dim tmpSection As Section Dim tmpObject As Object For Each tmpSection In m_Report.Sections For Each tmpObject In tmpSection.ReportObjects If IsObject(tmpObject) Then If tmpObject.Kind = crSubreportObject Then '//update location Set subReportObject = tmpObject Set subReport = subReportObject.OpenSubreport For Each dbTemp In subReport.Database.Tables dbTemp.SetLogOnInfo ServerName, DB_Name, UserName, Password lngIndex = 0 lngIndex = InStr(1, dbTemp.Location, ".") If lngIndex <> Empty Then '//if there is no "." then it may be SP, no need to substitute lngIndex = InStr(lngIndex + 1, dbTemp.Location, ".") dbTemp.Location = DB_Name & ".dbo." & Mid(dbTemp.Location, lngIndex + 1) End If Next End If End If
Next Next
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.