Re: IIF statement in query

Tech-Archive recommends: Speed Up your PC by fixing your registry



Ahh, the simplest methods are always the best! :-)

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------

"Duane Hookom" <DuaneAtNoSpanHookomDotNet> wrote in message
news:e6Hu5ho0GHA.4796@xxxxxxxxxxxxxxxxxxxxxxx
Or don't use an expression at all. Create a small lookup table
tblPriorities
=============================
Band
Priority
With values like
1 Very Low Priority
2 Low Priority
...

You can add this table to your query and join the band fields.

--
Duane Hookom
MS Access MVP

"Graham R Seach" <gseach@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:ummL0Zo0GHA.4648@xxxxxxxxxxxxxxxxxxxxxxx
SELECT band, IIf(band=1,"Very Low Priority", IIF(band=2,"Low Priority",
IIF(band=3,"Medium Priority", IIF(band=4,"High Priority","Very High
Priority")))) As Priority FROM Table1

...or...

SELECT band, Choose(band,"Very Low Priority", "Low Priority", "Medium
Priority", "High Priority","Very High Priority") As Priority FROM Table1

...or...

SELECT band, Switch(band=1,"Very Low Priority", band=2,"Low Priority",
band=3,"Medium Priority", band=4,"High Priority",band=5,"Very High
Priority") As Priority FROM Table1

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------

<cdolphin88@xxxxxxxxxxx> wrote in message
news:1157636779.130732.138620@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello,

I have the query below that I used an IIF statement to classified the
different band..

Is that possible to show me in only one column the different
classification? Because now it shows in 5 different column..

the query I'm using is like this:

SELECT band, IIF(band = 1, 'Very Low Priority'), IIF(band = 2, 'Low
Priority'), IIF(band = 3, 'Medium Priority'), IIF(band = 4, 'High
Priority'), IIF(band = 5, 'Very High Priority')
FROM Table1;

Cheers







.



Relevant Pages

  • Re: Shortcut Menu in AC 2007
    ... Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia ... Graham R Seach ... Microsoft Access MVP ...
    (microsoft.public.access.forms)
  • Re: DAO and Recordcount Max records
    ... Thanks for the info Dirk. ... Graham R Seach ... Microsoft Access MVP ... Dirk Goldgar, MS Access MVP ...
    (microsoft.public.access.modulesdaovba)
  • Re: Combo Box to open report
    ... Try rearranging the criteria to the following. ... SELECT 0 As PriorityID,"(All)" As Priority FROM tblPriority ORDER BY ... Doug Steele, Microsoft Access MVP ...
    (microsoft.public.access.queries)
  • Re: completing a query
    ... Doug Steele, Microsoft Access MVP ... FROM Causali RIGHT JOIN (Anagrafica RIGHT JOIN Transazioni ON ... Access will rearrange this query criteria into a more complex ...
    (microsoft.public.access.queries)
  • Re: completing a query
    ... Doug Steele, Microsoft Access MVP ... FROM Causali RIGHT JOIN (Anagrafica RIGHT JOIN Transazioni ON ... Access will rearrange this query criteria into a more complex ...
    (microsoft.public.access.queries)