Re: How to use "IIf" when there are multiple cases

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Another way to tackle this:

Your input is Right(zipcode,3)

Look for those chracters in a string:
"011 012 013 014 015 " ... etc
eg instr("011 012 013", right(zipcode,3))
derive an index from that by adding 3 and dividing by 4

use that index to find the resulting value using mid
someting like (unchecked):

mid("4433",instr("010 011 012 013", right(zipcode,3))+3)\4,1)

the \ is integer divide, / probably works.

HTH

"anthonyd" <anthonyd@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E0F555CE-AC18-4EEE-AA29-ABCA0098CFAB@xxxxxxxxxxxxxxxx
Does the "IIf" command work if I have a number of different cases, each of
which need to call out a different result? If so, what is the syntax for
it?
Is there a limit to the number of cases I might be able to have?

I am trying to enter a new column in a query called "Zone" that will
conditionally input a number based on the last 3 digits of a column called
"Zip code" in my Access query. For example, I'm trying to get the number 4
to
show up in "Zone" for all zip codes with the last 3 digits of 010-011.
Before I realized that ACCESS didn't support case-based conditions, I had
inputted the following:

Zone = CASE zip code
WHEN zip code Between LIKE *010 and LIKE *011 THEN 4
ELSE 3
END,
FROM Zone;

If ACCESS lacks this capability, is there anything else I could do? I was
considering doing an inner join, but wasn't sure how to get the query to
match just the last 3 digits of the zip code.

Any help would be greatly appreciated!


.



Relevant Pages

  • Re: How to use "IIf" when there are multiple cases
    ... I am trying to enter a new column in a query called "Zone" that will conditionally input a number based on the last 3 digits of a column called "Zip code" in my Access query. ... Before I realized that ACCESS didn't support case-based conditions, ...
    (microsoft.public.access.queries)
  • Re: interesting article on quantum cryptography
    ... you can gain the query much more ... Will you reveal outside the zone, ... preachs the yogi? ...
    (sci.crypt)
  • Re: Random_Picking_By_Percentage
    ... Static bRnd As Boolean ... Assuming that you have indexes on the proper fields that should be fairly quick for any one zone. ... For all zones in one query, the problem becomes more complex and performance could slow. ... If you can't add a field to voter_details, then you should be able to create a new table with two fields Voter_ID and GroupNumber and populate it with a query like the following. ...
    (microsoft.public.access.gettingstarted)
  • Re: CrossTab Query - Display Is null Fields
    ... I can filter this manually within the CrossTab Query: ... "Duane Hookom" wrote: ... Table = ZONE TABLE ...
    (microsoft.public.access.queries)
  • Re: Cannot join domain
    ... The DNS SRV record is not registered in DNS. ... When I do the nslookup query with MYDOMAIN.lan it works fine but of ... spelling of the zone in DNS? ...
    (microsoft.public.windows.server.networking)