Nested IIF Statement in expression builder (1 Viewer)

luzz

Registered User.
Local time
Yesterday, 18:50
Joined
Aug 23, 2017
Messages
346
Hi guys!

I am working on a project where i have to automate the gross weight for a company. Their gross weight is calculated by looking at a table with content and reference.

I am able to get the code running, however when include content or reference, the code will not work anymore. Is there any way i can fix this so that the expression builder is able to read my content and reference?

Thank you!

=IIf([AccessTotalsOur Qty]<130 And [Content]="100% cotton",[Nett Weight]+20,IIf([AccessTotalsOur Qty] Between 131 And 200 And [Content]="100% cotton",([Nett Weight]*115/100)+15,IIf([AccessTotalsOur Qty] Between 201 And 500 And [Content]="100% cotton"
 

ashleedawg

"Here for a good time"
Local time
Yesterday, 18:50
Joined
Jun 22, 2017
Messages
154
Count the number of the left-brackets and the number of the right-brackets. They should always be equal.
 

luzz

Registered User.
Local time
Yesterday, 18:50
Joined
Aug 23, 2017
Messages
346
Count the number of the left-brackets and the number of the right-brackets. They should always be equal.

The code work perfectly fine, if i did not add content and reference in hence, I am seeking help on how to enable the code to read the content and reference.
 

ashleedawg

"Here for a good time"
Local time
Yesterday, 18:50
Joined
Jun 22, 2017
Messages
154
...looking closer, you're missing the 2nd half of that statement. Perhaps a mis-copy/paste?

You're saying:


=iif ( UU=True AND VV=True,

then ResultAA,

otherwise; iif ( XX = True AND YY = True,

then ResultBB,

... but what happens after that???
(if that makes sense)
 

luzz

Registered User.
Local time
Yesterday, 18:50
Joined
Aug 23, 2017
Messages
346
This is my code before adding in the content and reference which work perfectly fine:

=IIf([AccessTotalsOur Qty]<130,[Nett Weight]+20,IIf([AccessTotalsOur Qty] Between 131 And 200,([Nett Weight]*0.15)+15,IIf([AccessTotalsOur Qty] Between 201 And 500,([Nett Weight]*0.1)+10,IIF([AccessTotalsOur Qty] Between 501 And 999 ,[Nett Weight]*0.11, IIf([AccessTotalsOur Qty] Between 1000 And 2000,[Nett Weight]*0.7,IIf([AccessTotalsOur Qty] Between 2001 And 4999,[Nett Weight]*0.5,IIf([AccessTotalsOur Qty] Between 5000 And 8000,[Nett Weight]*0.5,IIf([AccessTotalsOur Qty] Between 8001 And 10000,[Nett Weight]*0.5))))))))


This is the code which cannot work after i add in the content:

=IIf([AccessTotalsOur Qty]<130 And [Content]="100% cotton",[Nett Weight]+20,IIf([AccessTotalsOur Qty] Between 131 And 200 And [Content]="100% cotton",[Nett Weight]*(115/100)+15,IIf([AccessTotalsOur Qty] Between 201 And 500 And [Content]="100% cotton",[Nett Weight]*(110/100)+10,IIf([AccessTotalsOur Qty] Between 501 And 999 And [Content]="100% cotton",[Nett Weight]*(112/100),IIf([AccessTotalsOur Qty] Between 1000 And 2000 And [Content]="100% cotton",[Nett Weight]*(107/100),IIf([AccessTotalsOur Qty] Between 2001 And 4999 And [Content]="100% cotton",[Nett Weight]*(105/100),IIf([AccessTotalsOur Qty] Between 5000 And 8000 And [Content]="100% cotton",[Nett Weight]*(105/100),IIf([AccessTotalsOur Qty] Between 8001 And 10000 And [Content]="100% cotton",[Nett Weight]*(105/100),IIf([AccessTotalsOur Qty] Between 131 And 200 And [Content]="60% cotton 40% polyester",[Nett Weight]*(112/100))))))))))
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 11:50
Joined
Jan 20, 2009
Messages
12,851
This thread is really a continuation of a previous thread.

That question was about converting a badly constructed VBA function from Excel to use in Access. This question is about a badly constructed nested IIF() which is exactly where you got to in the other thread.

I didn't continue to assist there because you made no attempt to use the suggestions I had made.

You are still making the same mistake of repeating the tests in the nested IIF(). It is still completely the wrong approach and you ignored my advice to process this information as data rather than hard code.
 

Users who are viewing this thread

Top Bottom