Multiple IF statements for one column? (1 Viewer)

Espinoza84

Registered User.
Local time
Today, 09:11
Joined
May 30, 2008
Messages
55
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
 
Last edited:

KenHigg

Registered User
Local time
Today, 09:11
Joined
Jun 9, 2004
Messages
13,327
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

AWF VIP
Local time
Today, 09:11
Joined
May 2, 2008
Messages
3,428
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.
 
Last edited:

Espinoza84

Registered User.
Local time
Today, 09:11
Joined
May 30, 2008
Messages
55
thanks for the help guys, im going to try and implement your methods
 

Users who are viewing this thread

Top Bottom