Most efficient way to check for empty report

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In order to prevent report fields showing up with "#Error" if the report is
empty, I do a DCount against the report's underlying query, sending along a
where clause based on a set of user-selectable filters, and issue a "Report
empty" message if the DCount = 0.

I have found that if I use DCount("*","[myQuery],strWhere) instead of
DCount("[fieldName]","[myQuery]",strWhere), I sometimes get "Query too
complex" errors.

Why is this, and is there a more efficient way of dealing with empty reports?
 
Check out using the NoData event of the report. Use it to close the report.
Be sure your error handler in the code that opens the report checks for
Error 2501, which will be returned when the form's opening is cancelled.
 
Thanks, Ken. That did it, and it saved me running the query twice, as well.

Ken Snell said:
Check out using the NoData event of the report. Use it to close the report.
Be sure your error handler in the code that opens the report checks for
Error 2501, which will be returned when the form's opening is cancelled.

--

Ken Snell
<MS ACCESS MVP>

Brian said:
In order to prevent report fields showing up with "#Error" if the report
is
empty, I do a DCount against the report's underlying query, sending along
a
where clause based on a set of user-selectable filters, and issue a
"Report
empty" message if the DCount = 0.

I have found that if I use DCount("*","[myQuery],strWhere) instead of
DCount("[fieldName]","[myQuery]",strWhere), I sometimes get "Query too
complex" errors.

Why is this, and is there a more efficient way of dealing with empty
reports?
 
Back
Top