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
> good day all...
>
[quoted text clipped - 10 lines]
>
> 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

Signature
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Brook - 03 Dec 2005 04:50 GMT
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
> > good day all...
> >
[quoted text clipped - 29 lines]
> End If
> Resume Exit_Sub
Brook - 03 Dec 2005 04:54 GMT
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
> > good day all...
> >
[quoted text clipped - 29 lines]
> End If
> Resume Exit_Sub