IIF statement

Ms Kathy

Registered User.
Local time
Today, 18:04
Joined
May 15, 2013
Messages
190
I'm missing something somewhere but don't know where. This is what I typed in a query parameter (Access 2007). I tried adding/removing parenthesis and spaces and brackets with no luck.

Total: ((IIf([ProdBatch_Type] Like 'Batter*',[ProdBatch_Weight]*[ProdBatch_Number_Batches]*0.9 OR [ProdBatch_Type] = "donut",[ProdBatch_Weight]*[ProdBatch_Number_Batches]*1.31,[ProdBatch_Weight]*[ProdBatch_Number_Batches])

What I want to happen is: if the batch type begins with "batter" (i.e. batter_cakes, batter_cupcakes, etc.), then multiply the number of batches times the batch weight, and multiply by 0.9; or if the batch type is "donut" then multiply the number of batches times the batch weight, and multiply by 1.31; else just multiply the number of batches with the batch weight.

Thank you!
 
You can't put the OR clause where you have.

The format is simply IIF("Condition that evealuates to true of false here", TrueResult, FalseResult)

You have IIf(Like batter, DO sums OR Another condition here DO Other Sums) which doesn't make sense as far as access is concerned.
 
Note that the false result can be another IIf clause
Thus replace your or with
, IIF(
Then add another closing ) also as it stands remove the first two(

Brian
 
YES! Thank you Brian. This works!!

AdjTotal: (IIf([ProdBatch_Type] Like 'Batter*',[ProdBatch_Weight]*[ProdBatch_Number_Batches]*0.9,IIf([ProdBatch_Type]="donut",[ProdBatch_Weight]*[ProdBatch_Number_Batches]*1.31,[ProdBatch_Weight]*[ProdBatch_Number_Batches]))
 

Users who are viewing this thread

Back
Top Bottom