Get the query to show records

J

Jacques Latoison

I have a query that has a criteria making it possible to not have any
records when the query runs. How do you make the query show records of
Zero's when there are no records existing.
I already tried Nz for the query, but that doesn' work.

Thanks beforehand,
 
R

Rick B

Not sure what you mean. The query pulls up matching records. If none
match, none display.
 
J

Jacques Latoison

Understood, but then the report shows errors.
I need the query to show records when none exist.
 
R

Rick B

Well, you can't show records when none exist. You could build a test into
your report that displays or does something different if there are no
records found. Do a search and read through previous posts on the topic.
 
J

Jacques Latoison

I normally search first, then post when I wasn't able to find any previous
posts to resolve the issue. Currently there aren't any posts that cover the
issue, unless I'm using the wrong words in my search.

What should I be looking for when searching?
 
M

Michel Walsh

Hi,


You may try to include the logic inside a VBA subroutine, checking if
there is records, or not, with a DCount, as example.

Nz operates on a NULL, which IS a value, as much as 0 is a value (that
may means there is no money left in your bank account, but that IS a value).
If you have no value at all, if you are not client of the bank, Nz won't do
anything good. Possible scenario:

0 : you have no money left
NULL : the system is down, we cannot know how many money
is left
-no data- : there is no system to interact with in the first
place.


So, in VBA, you can use something like:

If 0=DCount("*", "tableName", criteriaHereAsString ) then
MsgBox "sorry boss, no record"
Else
... do whatever has to be done if there are records
End If



Hoping it may help,
Vanderghast, Access MVP
 
J

Jacques Latoison

Please refer to my new post with a subject of "Producing records from
nothing".
That may explain it better.
 
Top