467,877 Members | 1,202 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,877 developers. It's quick & easy.

query with no records...

I try this:
A first "group" query (sorry if this isn't the right name) count the records
from a table with a criteria (field1="A") and return counter1=10 records.
A second "group" query count the records from same table with another
criteria (field1="B") and return counter2=5 records.
A form display that the "B" records are (counter2*100/counter1)=50%

The problem is when there aren't "B" records! The form display nothing!
How could I set the counter2 field to zero? So the form will display 0%?
Apr 18 '06 #1
  • viewed: 1598
Share:
1 Reply
On Wed, 19 Apr 2006 00:40:29 +0300, "NewUser" <ne*****@freemail.gr>
wrote:

That would not help: 0/0 still produces an error: you can't divide by
zero.
One option to deal with these problems is the iif function:
dim a as integer
dim b as integer
dim c as single
a=<somequery>
b=<anotherquery>
c=iif(b=0, 0, a/b)

By the way, there is a more common way to deal with percentages than
what you are doing. Rather than your:
c=a*100/b
write:
c=a/b
Then format the field as Percentage, and a value like 0.5 will be
displayed as 50%.

-Tom.

I try this:
A first "group" query (sorry if this isn't the right name) count the records
from a table with a criteria (field1="A") and return counter1=10 records.
A second "group" query count the records from same table with another
criteria (field1="B") and return counter2=5 records.
A form display that the "B" records are (counter2*100/counter1)=50%

The problem is when there aren't "B" records! The form display nothing!
How could I set the counter2 field to zero? So the form will display 0%?


Apr 19 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Steve | last post: by
3 posts views Thread by Tom Mitchell | last post: by
5 posts views Thread by Daniel Tan | last post: by
6 posts views Thread by Martin Lacoste | last post: by
2 posts views Thread by Fendi Baba | last post: by
reply views Thread by jack112 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.