Detect empty report 
Author Message
 Detect empty report

I am making reports with VB6 and CR8 during runtime:

Dim rdApp As CRAXDRT.Application
Dim rpt As CRAXDRT.Report
Set rdApp = CreateObject("Crystalruntime.application")
rdApp.LogOnServer "pdssql.dll", "server", "database", user, password
Set rpt = rdApp.OpenReport(App.Path & "\report\" & rptfile)
With CRViewer1
    .ReportSource = rpt
    .ViewReport
End With

The above code runs well but I want to popup a message box if there is
no record and suppress the empty preview, I already have the "Suppress
printing if no record" setting checked in the report. Any solutions?
Thnaks.



Tue, 11 Nov 2003 07:30:29 GMT  
 Detect empty report
the following code, connect a recordset and set it the datasource from the
report, this is ok but the report table must be an Archive Definition Only
(ttx)

check out, this.

it works only if your report have a ttx file.

 Dim rsDat As New ADODB.Recordset

 Dim rpt As CRAXDRT.Report
 Set rdApp = CreateObject("Crystalruntime.application")
 rdApp.LogOnServer "pdssql.dll", "server", "database", user, password
 Set rpt = rdApp.OpenReport(App.Path & "\report\" & rptfile)

'this is the data source from the report

 rsDat.Open "select * from table", ConnectionString

 If rsDat.EOF And rsDat.BOF Then
   MsgBox ("There is no information on the report")
 Else
   rpt.Database.SetDataSource rsDat

   With CRViewer1
       .ReportSource = rpt
       .ViewReport
   End With

End If



Tue, 11 Nov 2003 23:14:36 GMT  
 Detect empty report
Thanks for your help. I am new to CR and don't know what is a ttx file.

Now I created a formula field in the report and check it value in VB
before displaying the report. This works for me but I don't know which
way is better.

Quote:

> the following code, connect a recordset and set it the datasource from the
> report, this is ok but the report table must be an Archive Definition Only
> (ttx)

> check out, this.

> it works only if your report have a ttx file.

>  Dim rsDat As New ADODB.Recordset

>  Dim rpt As CRAXDRT.Report
>  Set rdApp = CreateObject("Crystalruntime.application")
>  rdApp.LogOnServer "pdssql.dll", "server", "database", user, password
>  Set rpt = rdApp.OpenReport(App.Path & "\report\" & rptfile)

> 'this is the data source from the report

>  rsDat.Open "select * from table", ConnectionString

>  If rsDat.EOF And rsDat.BOF Then
>    MsgBox ("There is no information on the report")
>  Else
>    rpt.Database.SetDataSource rsDat

>    With CRViewer1
>        .ReportSource = rpt
>        .ViewReport
>    End With

> End If



Wed, 12 Nov 2003 06:29:28 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Empty report (no data) how to detect in CR 9, VB6 and Oracle

2. Empty Reports (Crystal Reports 7)

3. Best Way To Detect Empty Recordset?

4. Detecting when table is empty, then disabling all controls

5. Detect empty tags within a webbrowser.document

6. Detecting Empty Recordset Before Printing

7. Need help detecting empty recordset

8. How to detect an empty array

9. Problem with Empty or Null fields in a Table on a Report

10. empty report

11. empty Non-Deliverable report message body property

12. Why One Empty GROUP in Report ?

 

 
Powered by phpBB® Forum Software