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

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!
me_ponzioAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PWinterCommented:
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
me_ponzioAuthor Commented:
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
mlmccCommented:
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
me_ponzioAuthor Commented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.