Group:  Microsoft Access ยป microsoft.public.access.reports
Thread: IIF syntax problem...

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

IIF syntax problem...
AdamZ 22.09.2006 16:58:01
I have a crazy control source already which divides one expression in to
another (see below). The problem is the second half may be "0" and is throws
#num! when it is. I'd like to show a "-" instead of #num!". Any ideas on
how to format the IIF (i've tried a few differnt ways to no avail.)

Full code as is:

=(Count(IIf([Product Type]=Forms![Allied or Monster]!ProductTypeV And
[Packet Sent to Wholesaler YN]=True,[Wholesaler
ID],Null)))/(Count(IIf([Product Type]="Allied",[Wholesaler ID],Null)))

Thanks,
Adam
Re: IIF syntax problem...check for divide by 0, format
strive4peace <strive4peace2006[ at ]yahoo.com> 24.09.2006 15:17:29
Hi Adam,

how about this:

=iif(
Sum(
IIf(
[Product Type]="Allied"
,1
,0
)
)=0
,0
,Sum(
IIf(
[Product Type]=Forms![Allied or Monster]!ProductTypeV
And
[Packet Sent to Wholesaler YN]=True
,1
,0
)
)
/
Sum(
IIf(
[Product Type]="Allied"
,1
,0
)
)
)

then, use the Format property of the control to make zeros display as "-"

on format code -- there are 4 parts
1. format for positive numbers
2. format for negative numbers
3. format for 0 (zero)
4. format for null

ie:

#,##0;-#,##0;"-";"-"

Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*



AdamZ wrote:
[Quoted Text]
> I have a crazy control source already which divides one expression in to
> another (see below). The problem is the second half may be "0" and is throws
> #num! when it is. I'd like to show a "-" instead of #num!". Any ideas on
> how to format the IIF (i've tried a few differnt ways to no avail.)
>
> Full code as is:
>
> =(Count(IIf([Product Type]=Forms![Allied or Monster]!ProductTypeV And
> [Packet Sent to Wholesaler YN]=True,[Wholesaler
> ID],Null)))/(Count(IIf([Product Type]="Allied",[Wholesaler ID],Null)))
>
> Thanks,
> Adam

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net