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

IIF([And/Or/Else])

Status
Not open for further replies.

Tezdread

Technical User
Oct 23, 2000
468
GB
Hi all,

I'm having difficulties with a query (suprise suprise) maybe you can offer some help?

I need the query to check values in a field and if the value is between 1 and 5 it should give a level1, if it's between 6 and 10 give it a level2, if it's between 11 and 15 give it level3 etc...

I'm using the IIF statement and this is what I have working

IIF9[table1]=Y And [table2] Between 1 And 5,"Level1","Nothing")

This works fine but how can I get it to work out what level is allocated?

Tezdread
"With every solution comes a new problem"
 
And what about this ?
IIf([table1]=Yes, "Level" & (1+Int(([table2]-1)/5)), "Nothing")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
thanks PHV, it looks like it would work...could you explain what's happening with it?

I can see that if table1 = Yes it gets the value "Level" but what does the rest mean?



Tezdread
"With every solution comes a new problem"
 
T,

Open up Excel

enter numbers in column A

1
2
3
4
...

then enter the formula in column B and copy down using A1 instead of [table2]
[tt]
=1+Int((A1-1)/5)
[/tt]
it should explain what happening for you.


Skip,

[glasses] [red]Be advised:[/red] The dyslexic, agnostic, insomniac, lays awake all night wondering...
"Is there really a DOG?" [tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top