How do I set up a multiple condition expression in Access

M

MikeRoberts425

I want to set up an expression that does the following: I have two fields
'Impact' and 'Influence'; both of which contain either 0 or 1. I want to
create a third field 'Category' that displays A, B, C, or D depending on the
4 possible combinations of 0 and 1 in the 'Impact' and 'Influence' fields.
Please help
 
D

Douglas J Steele

Well, first of all I hope you're not trying to store this in a table. You
should never store values which are completely derivable from the values of
other fields in the same row.

Use a computed field in a query. In an empty cell on the "Field" row of the
query builder, type the following:

Category: IIf([Impact] = 0, IIf([Influence] = 0, "A", "B"), IIf([Influence]
= 0, "C", "D"))

The expression above assumes:

Impact = 0, Influence = 0 ==> Category = A
Impact = 0, Influence = 1 ==> Category = B
Impact = 1, Influence = 0 ==> Category = C
Impact = 1, Influence = 1 ==> Category = D

Of course, are you positive Impact and Influence will never hold anything
else?
 
Top