Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Reports / Printing / December 2005

Tip: Looking for answers? Try searching our database.

Report with no data?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brook - 02 Dec 2005 23:52 GMT
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
fredg - 03 Dec 2005 01:07 GMT
> 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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.