if query doesn't return results, have it report "No Records"

  • Thread starter Thread starter _Bigred
  • Start date Start date
B

_Bigred

(Access 2000)

i have a database that i want to set a query to return a list of records
that were "filed" between a certain date range. I know how to set up the
query for that. but can i somehow setup the query so that if I run it and
there are no records within the desired date range, it will return a
statement like: No Records Found or No Grievances Filed ?

So that I can base a report on the query, so when I do my monthly report on
grievances. it would either list the grievances filed or it would list "No
Records Found" or "No Grievances Filed"??

any help would be greatly appreciated,
_Bigred
 
A query does not have any direct method of passing a message such as this.

Go ahead and run your report, using the query as record source.
Code the Report's OnNoData event:

MsgBox "Nor records for this report."
Cancel = True

The message will display. The report will not run.

If the report was opened from a command button on a form, trap for error #
2501 "You have cancelled ... etc." in the code that opens the report.

If you wish to have the report print anyway, and
print out in the report that there are no records,
you could have a not visible label in the report
"No records to show."
Code the OnNoData event to make it visible.
Do NOT include the Cancel = True line.
 
thanks I will try this out.


Fredg said:
A query does not have any direct method of passing a message such as this.

Go ahead and run your report, using the query as record source.
Code the Report's OnNoData event:

MsgBox "Nor records for this report."
Cancel = True

The message will display. The report will not run.

If the report was opened from a command button on a form, trap for error #
2501 "You have cancelled ... etc." in the code that opens the report.

If you wish to have the report print anyway, and
print out in the report that there are no records,
you could have a not visible label in the report
"No records to show."
Code the OnNoData event to make it visible.
Do NOT include the Cancel = True line.

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.
 
I don't want a popup message box to return "no grievances filed". I would
want it to actually be displayed on a report.

Thanks,
_Bigred
 
Back
Top