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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IIf statement with In

Status
Not open for further replies.

r0nniem

Technical User
Dec 22, 2005
28
AU
I'm wanting to look at everyday info (weekdays and weekend) for all Zones, except only weekdays for Newcastle, Gold Coast and Perth zones.

What I've tried in the query, is creating a new field with: iif([RptZoneCat]=(In ("Newcastle","Gold Coast","Perth")),8,[DOW]). It doesn't like it. Is there another way to write it?

I hope this is enought info you need. Can you please help me out?
 
I don't agree with hard-coding values like this in expressions in queries. If something changes, you should not have to modify your expression buried in a query.

At the very least, you should create a small function that has arguments of RptZoneCat and DOW and returns either 8 or DOW. I would probably model this in my tables.

That said, you could try:
IIf(Instr("Newcastle~Gold Coast~Perth",[RptZoneCat])> 0,8,[DOW])

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top