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

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
 
B

Bas Cost Budde

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.
 
N

notDave

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
 
B

Bas Cost Budde

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.
 
G

Guest

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
 
J

John Vinson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top