dabdowb
asked on
Multiple If criteria in one expression vs Code builder
Is it possible to write one expression in an Access query where both criteria need to be met, two fields need to be updated and then one common exception if either of the conditions are not met? For example, see below expression:
X: IIf([Master Table]![Purchasing Price with Markup]>0,[Master Table]![Purchasing Price with Markup]*[Master Table]![System Quantity],IIf([Master Table]![Cost Per Unit]>0,[Master Table]![System Quantity]*[Master Table]![Cost Per Unit],"Neither"))
I want to avoid having to use VBA code for this expression if possible, but understand it may be necessary.
Thanks
X: IIf([Master Table]![Purchasing Price with Markup]>0,[Master Table]![Purchasing Price with Markup]*[Master Table]![System Quantity],IIf([Master Table]![Cost Per Unit]>0,[Master Table]![System Quantity]*[Master Table]![Cost Per Unit],"Neither"))
I want to avoid having to use VBA code for this expression if possible, but understand it may be necessary.
Thanks
Take a look at the Switch() Function instead of using IIF ...
mx
mx
ASKER
I actually found out about the AND feature, BUT the key change here is that there are two executions taking place if both conditions are met, as opposed to one. So, if both fields are greater than zero, then I have two seperate calculations that need to take place, but then if either of those conditionals are not greater than zero, only one result needs to be given for both.
In the meantime, I will check out this switch function.
Thanks,
Matt
In the meantime, I will check out this switch function.
Thanks,
Matt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks again for your help. Sorry for the delay, I was working with a co-worker on this project and waiting for them to do some testing before I could give the thumbs up or down. Cheers.
ASKER
Thanks again for your help. Sorry for the delay, I was working with a co-worker on this project and waiting for them to do some testing before I could give the thumbs up or down. Cheers.
no problem
thank you ..
mx
thank you ..
mx
x:iif([A]>0 AND [B]>0, "xxx", "yyy")