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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I find out if a report has no data using VB6 & CRPE? 1

Status
Not open for further replies.

Vogel

Programmer
Sep 7, 2001
7
US
I am executing a group of different Crystal Reports all at once using VB 6.0 and the Automation Server (CRPE) in Crystal Reports 7. Several of these reports may or may not have data associated with them. If there is no data, a blank page/screen is produced. I would like to supress the print/display of any blank reports. Other than executing each report's SQL statements before executing the report, can I use the automation server to determine programmatically if a report contains no records before it is sent to the printer/screen?
 
Thanks for the response, but I'm not sure I understood it. What type of object is crpe1 in your example? In other words, what CRPE object contains the records.read and when is it's value populated?

Thanx
 
I found the solution on my own.
Here it is....

Dim crpeApp As CRPEAuto.Application
Dim crpeRpt As CRPEAuto.Report
Dim lcount As Long

'Set the application object
Set crpeApp = New CRPEAuto.Application

'Set the report object
Set crpeRpt = crpeApp.OpenReport("YourFileName")

'Force report to run through the records
Call crpeRpt.ReadRecords

'Force report to run through the pages
'This creates a count the record count
lcount = crpeRpt.PrintingStatus.NumberOfPages

'Get the record count
lcount = crpeRpt.PrintingStatus.RecordsRead

'Check it
If lcount > 0 Then
Call crpeRpt.Preview
Else
MsgBox "No records"
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top