Query always returns a row

  • Thread starter Thread starter botuco via AccessMonster.com
  • Start date Start date
B

botuco via AccessMonster.com

Hello again:

I have a query based on a single table. The query has a date field which
receives parameters from a form (Between [date1] and [date2]) and multiple
calculated fields (mostly Count fields).

The problem is that even when there are no records matching the requested
dates, the query always returns 1 empty row. My biggest issue is that a
report based on this query always has data, so the On No Data Event never
triggers.

I have figured out that it has something to do with the Count function, but I
haven't been able to solve the problem.

Thanks for your help.
 
if the "empty" row has an * next to it it means that the query is
updateable, and that you can add a new record. If you do not enter any data
the recordset will not be updated.
 
The Count of a field will return 0 if it finds no records. If you add a
having clause, you can eliminate the return of the rows:

Having Count(SomeField) > 0
 
David, Lynn, thanks to both of you for your replies.

Adding the HAVING clause solved the problem.

Thanks again!
 
Back
Top