Have a field made up of six digits, fields are broken down into 3 pairs of two digits. These are then joined to a lookup table that has a two digit code and a description.
The issue is final output is to be one field showing only description.
I suppose I could do it numerically by looking at all the numbers, but since the description can be evaluated based on the first character, it would seem less typing.
Logic is if the first character of the description = "U" then look at the description that is equivalent to the 2nd pair of numbers, and if that is also evaluating to "U", look at the 3rd pair's description. If the last pair is also "U", then display the "U" description of the first pair.
994170
99=UNLA
41=UNDC
70=SPAS
Therefore, the query should display SPAS
I first tried this and didn't get the results I needed:
IIf(Left([Maj1].[EMTCode],1)="U",[Maj2].[EMTCode],
IIf(Left([Maj2].[EMTCode],1)="U",[Maj3].[EMTCode],
[Maj1].[EMTCode]))
I next tried this on the field grid:
IIf(Left([Maj1].[EMTCode],1)="U",
IIf(Left([Maj2].[EMTCode],1)="U",
IIf(Left([Maj3].[EMTCode],1)="U",[Maj1].[EMTCode],
IIf(Left([Maj2].[EMTCode],1)="U",
IIf(Left([Maj3].[EMTCode],1)="U",[Maj2].[EMTCode],
[Maj3].[EMTCode])))))
I probably need more iifs? as it currently is showing a lot of blanks rather than putting in a description. The first version doesn't have blanks, all fields are filled in.
Thanks.
The issue is final output is to be one field showing only description.
I suppose I could do it numerically by looking at all the numbers, but since the description can be evaluated based on the first character, it would seem less typing.
Logic is if the first character of the description = "U" then look at the description that is equivalent to the 2nd pair of numbers, and if that is also evaluating to "U", look at the 3rd pair's description. If the last pair is also "U", then display the "U" description of the first pair.
994170
99=UNLA
41=UNDC
70=SPAS
Therefore, the query should display SPAS
I first tried this and didn't get the results I needed:
IIf(Left([Maj1].[EMTCode],1)="U",[Maj2].[EMTCode],
IIf(Left([Maj2].[EMTCode],1)="U",[Maj3].[EMTCode],
[Maj1].[EMTCode]))
I next tried this on the field grid:
IIf(Left([Maj1].[EMTCode],1)="U",
IIf(Left([Maj2].[EMTCode],1)="U",
IIf(Left([Maj3].[EMTCode],1)="U",[Maj1].[EMTCode],
IIf(Left([Maj2].[EMTCode],1)="U",
IIf(Left([Maj3].[EMTCode],1)="U",[Maj2].[EMTCode],
[Maj3].[EMTCode])))))
I probably need more iifs? as it currently is showing a lot of blanks rather than putting in a description. The first version doesn't have blanks, all fields are filled in.
Thanks.