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))
ilfocorpAsked:
Who is Participating?
 
Rey Obrero (Capricorn1)Commented:



=sum(iif([ps1_bkfst_food] <> 0,([ps1_bkfst_food]-[ps13_bkfst_food])/[ps1_bkfst_food],0))
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:

How about this:

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

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

try this
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
You had a extra paren on the end ... if that's what you mean by blowing up?

mx
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
And maybe this:

=IIf([ps1_bkfst_food] = 0, , 0, sum(([ps1_bkfst_food] - [ps13_bkfst_food]) / [ps1_bkfst_food]))
0
 
ilfocorpAuthor Commented:
Thanks everyone. This is the solution that actually worked.  I got errors all the other solutions but appreciate the support and effort.
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
What error do you get with the solution I posted @ http:#a37298940  ?

mx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.