IIF statement (1 Viewer)

Ms Kathy

Registered User.
Local time
Today, 07:43
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!
 

Minty

AWF VIP
Local time
Today, 12:43
Joined
Jul 26, 2013
Messages
10,371
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.
 

Brianwarnock

Retired
Local time
Today, 12:43
Joined
Jun 2, 2003
Messages
12,701
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
 

Ms Kathy

Registered User.
Local time
Today, 07:43
Joined
May 15, 2013
Messages
190
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

Top Bottom