Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with coding - if...then..elseif statement?

Status
Not open for further replies.

piper3d

Technical User
Aug 8, 2002
6
US
I need some help with some code. I am new to this. Can someone please help me. How do I do this?

the table is apparel
the field in my table category
the contents of the field category are accessories and 2004 collection. There are about 72 items, some have accessories and the rest are 2004 collection.

I want to look in the field "category" from the table "apparel". If the contents that are located in the field "category" equals "accessories" then show me the number "26" or if the contents that are located in the field "category" equals "2004 collections" then show me the number "24" and if none of the contents in the field "category" matches either "accessories" or "20004 collection" then show me the number "1".

I want to put the code in a module so I can call the function in a query.

Brian
 
Something like this in the Query Design Window?
CatNumber: IIf(apparel.category="accessories", 26, IIf(apparel.category="2004 collections", 24, 1))



Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
This works perfectly!

I didn't know you could use more than one iif like that. That is much better than if..then..elseif.

THANK YOU!!!

You saved the day.

Thanks,
Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top