Crystal report w/subreport: "Suppress Printing if No Records" is ignored by VB6
Posted on 2006-03-21
I created a report in Crystal Reports 8.5, which contains a subreport. However, not always there is data for the subreport for each of the records in the main report. I don't want to show the subreport for those records because the subreport contains text in the 'Details' section (I can't get rid of that text and I can't put it in the headers).
The solution on Crystal Reports is just setting the "Suppress Printing if No Records" option on. I did this, and it works great.
The problem is that when I call the report from Visual Basic 6, this option is ignored, and I get the subreport for every record in the report, regardless of whether there are records or not in it.
I am using the CRViewer object in VB (version 8.5). Just in case it has anything to do with it, the code I'm using to call the report is this:
Dim crApp As CRAXDRT.APPLICATION
Dim crRept As CRAXDRT.Report
' Open Report File
Set crApp = New CRAXDRT.APPLICATION
Set crRept = New CRAXDRT.Report
Set crRept = crApp.OpenReport(App.Path + "\reports\" + report_name)
' Logon to SQL server
crRept.Database.LogOnServer "p2ssql.dll", "ServerName", "DatabaseName", user, password
'Show the report using the object CRViewer
CRViewer1.ReportSource = crRept
Any ideas on why this is happening? Thanks!