Simplify an expression

A

Alex

I need help with the below query expression. I've tried many things with no
luck. This is what I need:
If M_B = "" then return "",
If M_B = t OR p AND ST = 6, nz(DLookUp("[MCSOne]","SASQueryOne","[CP] = '" &
[PartOne] & "' AND [ST] = '1'"). If that is not true then
nz(DLookUp("[MCSOne]","SASQueryOne","[CP] = '" & [PartTwo] & "' AND [ST] =
'1'") etc. . .
If M_B = a OR w then return DMin("[MCSOne]","SASQueryOne","[CP] Like '" &
[CP] & "*'").
If none of these things are true then return [MCSOne].

The actual DLookups and DMIN work fine. I'm just having trouble putting
them together in this query expression. Thanks for your help.


MCSTwo: IIf([MCSOne]="","",IIf([M_B]="T" Or [M_B]="P" And
[ST]="6",Nz(DLookUp("[MCSOne]","SASQueryOne","[CP] = '" & [PartOne] & "' AND
[ST] = '1'"), Nz(DLookUp("[MCSOne]","SASQueryOne","[CP] = '" & [PartTwo] & "'
AND [ST] = '1'"), nz(DLookUp("[MCSOne]","SASQueryOne","[CP] = '" &
[PartThree] & "' AND [ST] = '1'"), Nz(DLookUp("[MCSOne]","SASQueryOne","[CP]
= '" & [PartFour] & "' AND [ST] = '1'"),
Nz(DLookUp("[MCSOne]","SASQueryOne","[CP] = '" & [PartFive] & "' AND [ST] =
'1'"), Nz(DLookUp("[MCSOne]","SASQueryOne","[CP] = '" & [PartSix] & "' AND
[ST] = '1'"),Nz(DLookUp("[MCSOne]","SASQueryOne","[CP] = '" & [PartSeven] &
"' AND [ST] = '1'"), Nz(DLookUp("[MCSOne]","SASQueryOne","[CP] = '" &
[PartEight] & "' AND [ST] = '1'"),Nz(DLookUp("[MCSOne]","SASQueryOne","[CP] =
'" & [PartNine] & "' AND [ST] = '1'"),IIf([M_B]="A" Or
[M_B]="W",DMin("[MCSOne]","SASQueryOne","[CP] Like '" & [CP] &
"*'"),[MCSOne])))))))))))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top