MS access query - change values in result set using if statements, etc.


I would like to create a make table query in access.    Before populating the results in the table, I want to change values in the results for one of the columns using "IF" statements.

e.g. If value = "XXX" then
            change value to "YYY"

Should I put the If statements in the SQL statement?  

How do I change the values?

Thanks for your help.

FROM [tbl1] INNER JOIN [tbl2] ON [tbl1].[Customer Account Number] = [tbl2].AccountNumber
WHERE ((([tbl1].[Customer Account Create Date]) Between "20110901" And "20111001"));

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:
use the IIF function , IIf(expr, truepart, falsepart)

SELECT X, Y, Z, IIf([fieldName]="xxx","yyy",[fieldName]) as Z
From ....
lchaAuthor Commented:
thanks so much for your resoponse capricorn1

To clarify I need, I am actually looking for 3 different values in the column results and need to change those values to more something more understandable to the

Will the IIF function allow me to do what I need because it is limited to returning 2 different values right?

iif ([Qty] > 10, "large", "small")


Rey Obrero (Capricorn1)Commented:
post the conditions
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

lchaAuthor Commented:
sorry that this isn't obvious to me ... can you give an example

I need to check for 3 different values in the column results and change the values for all of them.
iif ([fieldname1]="xxx", "yyy")
iif ([fieldname1]="abc", "xxx")
iif ([fieldname1]="def", "zzz")

Rey Obrero (Capricorn1)Commented:

iif ([fieldname1]="xxx", "yyy", iif ([fieldname1]="abc", "xxx",iif ([fieldname1]="def", "zzz",[fieldname1])))

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Alternatively, you can use the SWITCH function which allows multiple conditions.

SWITCH([fieldname1]="xxx", "yyy", [fieldname1]="abc", "xxx", [fieldname1]="def", "zzz")

Open in new window

lchaAuthor Commented:
that worked, thank you! :)
lchaAuthor Commented:
thanks Thomasian, I will look into your solution as well later.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.