I'm trying to figure out how to access, in a report, the values given to the criteria in the underlying query when no records are found. I've searched the forum to see if a similar case has come up before, with no success.
Here's the situation:
I have a query on an Access 2003 table with a DueDate field that has the Criteria field: Between [Start Due Date] and [End Due Date]. When the query is run, it prompts the user for [Start Due Date] and [End Due Date] and only returns those records that have a DueDate falling within that range. (Yes, I know this is basic stuff, I just want to be thorough. And I may be making a basic mistake I don't even comprehend.)
In the report that uses this query as its source, I have a text field in the header with this formula as data source--
="Documents with Due Date Between " & [Start Due Date] & " and " & [End Due Date]
--which thereby shows the date range entered by the user, a handy reference if the report is printed or exported to file and distributed.
My problem occurs when no data is returned for a given date range, in which case the text field comes out as #Error. As a stopgap measure, I revised the formula to read--
=IIf(IsError([Start Due Date]),"No Documents found for given Due Date range","Documents with Due Date Between " & [Start Due Date] & " and " & [End Due Date])
--but that doesn't tell anyone WHAT date range returned no records.
So the question I have is, is it possible to somehow access, in the report, the values given criteria in the underlying query when no records are returned by the query? Presumably, they're in there somewhere, since they were used to compare with the DueDate field in the table, but is there any way we can show them in the report?
I have been told of a work-around, but it involves considerable revision to my MS Access form, as well as all queries and reports with criteria, and introduces an extra level of administration to the whole report operation wherein the criteria are entered in text fields on the form, which applies the criteria to the query when opening the report, which refers to those text fields on the form for the criteria values. So I’m hoping to find some way to “winkle out” the desired values from the query.