Field conversion

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I have a field called STATUS, in it you will find one of the next values:
COMP, IND, and COUP. I want to have another column which generate a number
acording to the STATUS, for example: 1 when COMP appear, 2 when IND appear
and 3 when COUP appear.
What expression I must write in my query, so that I get this results. Thanks
 
viddom said:
Hi, I have a field called STATUS, in it you will find one of the next
values: COMP, IND, and COUP. I want to have another column which
generate a number acording to the STATUS, for example: 1 when COMP
appear, 2 when IND appear and 3 when COUP appear.
What expression I must write in my query, so that I get this results.
Thanks

NewFieldName: Switch([STATUS]="COMP", 1, [STATUS]="IND", 2, [STATUS]="COUP", 3)

Anytime you need something similar with more than a handful of values, it would
be better to create a small table with two fields, one for the text and another
for the number. Then you just include that table in your query and you can pull
in the other value from there. A big advantage of that method is that you
simply edit the table to account for new values that might come along later
without having to redesign the query.
 
Back
Top