View Full Version : Multiple IF statements for one column?


Espinoza84
06-05-2008, 09:20 AM
Hello I have a table I am trying to run a query from.

One of my columns name is "Sports"

the data in this column has over 15 sports, showing multiple times, because this table is for athletes and what sports do they play.

In my query I want to do an if statement to display A for Soccer, B for Football, C for Basketball, etc etc.

So if soccer is under the column sports, I want it to show "A" not Soccer, football will be "B" etc etc.

Can someone help me with the syntax for this?

PS: only one sport is in a field in the column like:
soccer
basketball
baseball

not like:
baseball, soccer, basketball

KenHigg
06-05-2008, 09:30 AM
I would suggest you do a table that contains the conversions and link to it instead of clunking around with a bunch of embedded IIf()s.

MSAccessRookie
06-05-2008, 09:36 AM
Hello I have a table I am trying to run a query from.

One of my columns name is "Sports"

the data in this column has over 15 sports, showing multiple times, because this table is for athletes and what sports do they play.

In my query I want to do an if statement to display A for Soccer, B for Football, C for Basketball, etc etc.

So if soccer is under the column sports, I want it to show "A" not Soccer, football will be "B" etc etc.

Can someone help me with the syntax for this?

If you had a table for sports similar to the one below, then you could link to it via Sports name or Primary Key, to get the Letter Key that you want. It would also allow you to add more sports as time goes along.

-------------------------------

Primary Key (AutoNumber)
Sports Name (Text)
Letter Key (Text)


It would seem that Ken beat me to it with similar advice. Hope this helps you to make it work.

Espinoza84
06-05-2008, 10:08 AM
thanks for the help guys, im going to try and implement your methods