If query results exist, export query, else don't?

  • Thread starter Thread starter notDave
  • Start date Start date
N

notDave

I have a module that grabs records from a table and throws
them into a record set. Then it prints a particular
report for each record in the record set, using the record
as a filter. My issue is that sometimes there are no
results for a particular record, but it generates a
(blank) report.
Any suggestions as to how to not export/print this report
when the filtered query doesn't produce any records?

~notDave
 
notDave said:
I have a module that grabs records from a table and throws
them into a record set. Then it prints a particular
report for each record in the record set, using the record
as a filter. My issue is that sometimes there are no
results for a particular record, but it generates a
(blank) report.
Any suggestions as to how to not export/print this report
when the filtered query doesn't produce any records?

A report has a NoData property, or event, talking from memory. See if it
serves you.
 
I've seen that, but I don't know what to put there (event
Procedure wise) to make it skip the export and move to the
next record.

~notDave
 
notDave said:
I've seen that, but I don't know what to put there (event
Procedure wise) to make it skip the export and move to the
next record.

Cancel = True?

AFAICS the event fires when the report has an empty recordset.

You can consider testing this from your export procedure as it should be
possible to decide already then. But see what gives.
 
if you are dumping the data in a recordset, you can use
the EOF.
IF recordset.EOF then
msgbox("no records")
exit sub
end if
 
I have a module that grabs records from a table and throws
them into a record set. Then it prints a particular
report for each record in the record set, using the record
as a filter. My issue is that sometimes there are no
results for a particular record, but it generates a
(blank) report.
Any suggestions as to how to not export/print this report
when the filtered query doesn't produce any records?

~notDave

Use the Report's NoData event to cancel the report before opening it.
Or, use DCount() to count the records that will be returned using the
filter criterion, and just skip that report if there are none.

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
Back
Top