?
Solved

Crystal report w/subreport: "Suppress Printing if No Records" is ignored by VB6

Posted on 2006-03-21
5
Medium Priority
?
4,828 Views
Last Modified: 2012-08-13
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
CRViewer1.ViewReport

Any ideas on why this is happening? Thanks!
0
Comment
Question by:me_ponzio
  • 2
4 Comments
 
LVL 6

Expert Comment

by:PWinter
ID: 16252378
Hi.

First I'd suggect to check is setting connection string for the subreport. You remember that moving a report from design to runtime environment you have to reset datasource for the report and for each of the subreports specifically.

Thank you,
PW
0
 

Author Comment

by:me_ponzio
ID: 16258585
Thanks PW. I'm not sure how to do what you say, though. I am not setting any connection strings from VB to get a recordset. Instead, I created a report in Crystal Reports specifying which stored procedure to use for the main report and which sp to use for the subreport. All I'm doing from VB is connect to the database and call the report. Is that not the way to do it? Thanks.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 16264860
As long as it is the same database in the exact same location it should work.  However if the database is on a different server, in a different directory, etc. you need to pass the logon information to the subreport as well.

mlmcc
0
 

Accepted Solution

by:
me_ponzio earned 0 total points
ID: 16270436
It is in the same location, and the report does work and shows the same data in both Crystal Reports and from Visual Basic.

The problem is that the report doesn't have the same behavior when run from VB as from CR. When I run it inside CR it doesn't print the subreport if it doesn't contain records from the database (which is what I want), whereas when I call it from VB, it shows the blank subreport (full of text, headers, etc!).

I did find a workaround to this, because I need to get the reports ready ASAP. My solution is to have formula fields instead of fixed text fields, and only display those fields when there is a database record. This involves more work and time, but solves the problem.

I still would love to know what could be wrong in VB - but if no one has suggestions on this, I'll close the question.

Thanks.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month13 days, 16 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question