MS Access: Need to add another condition to IIF statement

Hello,
I'm trying to return the value of one column based on the condition of other columns.  If Value2 = 0, then return Value1.  But, if Value1 = 0, then return Value3. Can you please review my IIf statement and tell what I need to add for completion?  

For example, in the attached database (Record 1), should return 900 since Value1  and Value2 = 0, but there is an amount in Value3.
Database-Price2.mdb
Wonderwall99Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:
test this

SELECT [Item Table].[Item#], [Item Table].Value1, [Item Table].Value2, [Item Table].Value3, IIf([Value2]=0 And [Value1]=0,[Value3],IIf([Value1]>0,[Value1],[Value2])) AS Expr1
FROM [Item Table];
0
Rey Obrero (Capricorn1)Commented:
or maybe this

SELECT [Item Table].[Item#], [Item Table].Value1, [Item Table].Value2, [Item Table].Value3, IIf([Value2]=0 And [Value1]=0,[Value3],IIf([Value2]>0,[Value2],[Value1])) AS Expr1
FROM [Item Table];
0
Dale FyeOwner, Developing Solutions LLCCommented:
Personally, I like to put this type of convoluted logic in a function, which will allow me to document, via remark statements, my business logic.  This is much easier to maintain in the long run.
0
Rey Obrero (Capricorn1)Commented:
another version

SELECT [Item Table].[Item#], [Item Table].Value1, [Item Table].Value2, [Item Table].Value3, IIf([Value2]=0 And [Value1]=0,[Value3],IIf([Value2]=0,[Value1],[Value2])) AS Expr1
 FROM [Item Table];
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Gustav BrockCIOCommented:
This one exactly mimics your English definition:

SELECT
    [Item Table].[Item#],
    [Item Table].Value1,
    [Item Table].Value2,
    [Item Table].Value3,
    IIf([Value1]=0,IIf([Value2]=0,[Value3],[Value2]),[Value1]) AS ValueX
FROM
    [Item Table];

/gustav
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.