Report with no data?

G

Guest

good day all...

I have a report (rptpaymenthistory) that I run from my invoincing form.
The report has a main report and subreport that pulls data from a
tlbinvoicepayments.

Currently if I click my button to open the payment history report, the
report opens even if there is no data from the tblinvoicepayments, is there a
way that I can have it set up so that a message box will pop up if there
have been no payments made / no data to report?

Any ideas? suggestions?

Brook
 
F

fredg

good day all...

I have a report (rptpaymenthistory) that I run from my invoincing form.
The report has a main report and subreport that pulls data from a
tlbinvoicepayments.

Currently if I click my button to open the payment history report, the
report opens even if there is no data from the tblinvoicepayments, is there a
way that I can have it set up so that a message box will pop up if there
have been no payments made / no data to report?

Any ideas? suggestions?

Brook

Code the Report's OnNoData event:

MsgBox "Nothing going on today."
Cancel = True

This will generate error 2501 which you can trap in the event that you
used to open the report.

On Error Goto Err_Handler
DoCmd.OpenReport "ReportName", acViewPreview
Exit_Sub:
Exit Sub
Err_Handler:
If Err = 2501 Then
Else
MsgBox "Error #: " & Err & " " & Err.Description
End If
Resume Exit_Sub
 
G

Guest

hello fred...

thanks for the response... I tried exactly what you posted but the report
is still opening... i'm not getting a message box...

Do I need to place any code in the subreport OnNoData event?

Thanks,

Brook
 
G

Guest

i'm not sure if this helps, but here is my code that I currently have for
opening my report...

--- begin code ---

Private Sub cmdpaymenthistory_Click()
Dim strReportName As String
Dim strcriteria As String

If NewRecord Then
MsgBox "This record contains no data. Please select a record to
print or Save this record." _
, vbInformation, "Invalid Action"
Exit Sub
Else
strReportName = "rptpaymenthistory"
strcriteria = "[invoiceid]= " & Me![invoiceid]


DoCmd.OpenReport strReportName, acViewPreview, , strcriteria


If MsgBox("Do you want to save the report to disk?", vbYesNo +
vbQuestion, "Save Report") = vbYes Then

strOutputName = "D:\Karma Imports\Invoices\" & (Me!invoicenumber) &
"Payment History" & " - " & Format(Me!invoicedate, "mmddyyyy") & " - " &
Format(Date, "mmddyyyy") & ".snp"



DoCmd.OutputTo acOutputReport, strReportName, acFormatSNP,
strOutputName, True
End If


End If
End Sub


End Code ---

Brook
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top