Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to avoid blank report in VB6 1

Status
Not open for further replies.

ndp

Programmer
Mar 3, 2003
121
0
0
US
Hi,
I am developing an application which creates pdfs for several Crystal reports(version 8.5). It works fine. Only thing is I am passing parameters from VB code. If there is no record for that parameter, the reports still creates pdf. I want to know if there is any way in VB code, I can check if the report doesn't have any data, so that I can avoid creating pdf of that report.

I am using Visual Basic 6 and Automation server.
Here is some part of my code...

Public crpAPP As New CRPEAuto.Application
Public crpReport As New CRPEAuto.Report

crpReport.SelectPrinter "winspool", "Acrobat PDFWriter", "LPT1"
crpReport.PageSetup.PaperSize = iPaperSize
crpReport.PageSetup.PaperOrientation = iOrin
crpReport.PrintOut False, 1

My question is, how do I check if the report has 0 records?

Any suggestion would be most welcome!
Thanks in advance,
ndp
 
What you need to do is use the PrintingStatus object along with the ReadRecords method. Prior to calling the PrintOut method, do the following:

Dim crpPrintStatus as PrintingStatus

Set crpPrintStatus = crpReport.PrintingStatus

crpReport.ReadRecords
If crpPrintStatus.RecordsRead > 0 then
crpReport.PrintOut False,1
End If

 
Thank you FVTrainer for the solution!
You have pointed me in absolutely correct direction. I put the code as you mentioned. But, somehow it never goes through the if statement. If it has more than 0 records then it should print, but it never goes to crpreport.printout even if there are records.

I know I am almost there but it Looks like I am still missing something. Can you think of something?

Thanks,
ndp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top