Link to home
Start Free TrialLog in
Avatar of ilfocorp
ilfocorp

asked on

IF Statement

Hello, I am trying to get my syntax right in this report textbox equation.  Can someone help get the commas and/or paranthesis right.  My goal is to make sure that I'm not trying to subtract or divide with zero.  Thanks.

Current Script Blowing Up:

=sum(iif([ps1_bkfst_food] <> 0,([ps1_bkfst_food]-[ps13_bkfst_food])/[ps1_bkfst_food]),0))
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image


How about this:

=sum(IIf([ps1_bkfst_food] <> 0, ([ps1_bkfst_food] - [ps13_bkfst_food]) / [ps1_bkfst_food]), 0)

mx
select sum(iif([ps1_bkfst_food] <> 0,([ps1_bkfst_food]-[ps13_bkfst_food])/[ps1_bkfs_food],0))

try this
You had a extra paren on the end ... if that's what you mean by blowing up?

mx
And maybe this:

=IIf([ps1_bkfst_food] = 0, , 0, sum(([ps1_bkfst_food] - [ps13_bkfst_food]) / [ps1_bkfst_food]))
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ilfocorp
ilfocorp

ASKER

Thanks everyone. This is the solution that actually worked.  I got errors all the other solutions but appreciate the support and effort.
What error do you get with the solution I posted @ http:#a37298940  ?

mx