By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,660 Members | 1,037 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,660 IT Pros & Developers. It's quick & easy.

query with no records...

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.