Sum an IIF

S

SAC

I have a control with a data source as follows:

=(IIf([chktaxable]=-1,[txtPriceNet],0)

I'd trying to set up another control that would sum this as follows:

=Sum(IIf([chktaxable]=-1,[txtPriceNet],0))

but I get an error.

Any ideas on what I can do?

Thanks.
 
J

Jeanette Cunningham

SAC,
try this:

=IIf([chktaxable]=-1,Sum([txtPriceNet]),0)

Jeanette Cunningham
 
S

SAC

Thanks!!
Jeanette Cunningham said:
SAC,
try this:

=IIf([chktaxable]=-1,Sum([txtPriceNet]),0)

Jeanette Cunningham

SAC said:
I have a control with a data source as follows:

=(IIf([chktaxable]=-1,[txtPriceNet],0)

I'd trying to set up another control that would sum this as follows:

=Sum(IIf([chktaxable]=-1,[txtPriceNet],0))

but I get an error.

Any ideas on what I can do?

Thanks.
 
J

John W. Vinson

I have a control with a data source as follows:

=(IIf([chktaxable]=-1,[txtPriceNet],0)

I'd trying to set up another control that would sum this as follows:

=Sum(IIf([chktaxable]=-1,[txtPriceNet],0))

Not sure why that shouldn't work... but you can be sneaky and not use any IIF
at all!

Abs(Sum([chktaxable]*[txtPriceNet]))

will multiply the value of txtPriceNet by -1 if the item is taxable and by 0
if it isn't.

If txtPriceNet is a *form textbox* though, you can't sum it; you can only sum
field values in the form's recordsource query/table. You may need to do this
based on the actual table fieldname (PriceNet?) instead of the form control.

John W. Vinson [MVP]
 
S

SAC

Thanks!!
Jeanette Cunningham said:
SAC,
try this:

=IIf([chktaxable]=-1,Sum([txtPriceNet]),0)

Jeanette Cunningham

SAC said:
I have a control with a data source as follows:

=(IIf([chktaxable]=-1,[txtPriceNet],0)

I'd trying to set up another control that would sum this as follows:

=Sum(IIf([chktaxable]=-1,[txtPriceNet],0))

but I get an error.

Any ideas on what I can do?

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top