Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to detect empty Record Source in report detail_format()?

Posted on 2006-11-18
3
Medium Priority
?
489 Views
Last Modified: 2012-06-27
I have a report where I have a detail_format routine to do some additional formatting of the detail lines. This works just fine as long as the record source has rows. However, the user is able to select date ranges, etc in such a way as to result in no rows in the record source query. I would think that Access would never call the detail_format() routine, but it does. The first reference to a bound object causes the report to blow up with: "The Output To action was canceled". In the debugger, it indicates "You entered and expression that has no value" and the debug line highlights the 1st reference to a bound object.

I won't bother asking why Access goes ahead and calls the detail_format() function with no data. What I would like to know is 1) what is the proper way to detect an empty record source in the detail_format() function and 2) how do I gracefully exit (what does the Cancel parameter do? I haven't quite figured this out. I've looked in the MS Access VBA Reference, but can't locate detail_format() under methods, events or functions).
0
Comment
Question by:jmarkfoley
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 65

Accepted Solution

by:
rockiroads earned 2000 total points
ID: 17973919
U can use the no data event to track this



Private Sub Report_NoData(Cancel As Integer)
    MsgBox "Sorry but no data found"
    Cancel = true
End Sub



0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17973920
now since this reports a failure, your open report call will trigger an error, u can easily track this anyway
so if u ignore error number 2501, u should be okay

eg

    On Error GoTo ReportLoad_Error
   
    DoCmd.OpenReport "myreport", acViewPreview
   
    Exit Sub
   
ReportLoad_Error:
    If Err.Number <> 2501 Then MsgBox Err.Description
0
 
LVL 1

Author Comment

by:jmarkfoley
ID: 17973950
I chose your first solution because I do want to tell the user there is no date. Thanks.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question