I am writing a query that uses a switch statement. Here's my
statement:
Region: Switch([STATE_CODE]="PA" Or
[STATE_CODE]="DE","PennDel",[STATE_CODE]="NY" Or
[STATE_CODE]="NJ","Atlantic")
Basically I have a new field named "Region". If the STATE_CODE value
is PA or DE, then Region="PennDel". If the STATE_CODE value is NY or
NJ, then Region="Atlantic".
The query works like a charm right now, but I need to add a piece to my
statement. I need to add a piece that says "If the STATE_CODE value is
not one of: PA, DE, NY or NJ, then Region=Other". Or it could be
similar to an IF...Else statement. Where if the value of STATE_CODE
doesn't fit one of the other options, make it "Other".
Not sure how to write it correctly. Can someone help? 3 13443
Region: Switch([STATE_CODE]="PA" Or
[STATE_CODE]="DE","PennDel",[STATE_CODE]="NY" Or
[STATE_CODE]="NJ","Atlantic", "Steve needs this answer"=True,"Tell PC
Datasheet we miss him")
Chris Mills
Your Access Resource http://www.accessresource.somee.com/Specials.html
Wouldn't everyone would use a simple class for this?
Dim aRegion(65 To 90, 65 To 90) As String
Private Sub Class_Initialize()
aRegion(Asc("D"), Asc("E")) = "PennDel"
aRegion(Asc("N"), Asc("J")) = "Atlantic"
aRegion(Asc("N"), Asc("Y")) = "Atlantic"
aRegion(Asc("P"), Asc("A")) = "PennDel"
End Sub
Property Get Region(ByVal StateCode As String) As String
Dim b() As Byte
StateCode = StrConv(Left(StrConv(StateCode, vbUpperCase), 2),
vbFromUnicode)
b = StateCode
Region = aRegion(b(0), b(1))
If Len(Region) = 0 Then Region = "Other"
End Property
and then call a UDF (that referenced the class) in the query.
Hello.
Please excuse my ignorance but couldn't it be done by
just adding a bit more to your original code by adding a
comma and then "Other"? See below.
Region: Switch([STATE_CODE]="PA" Or
[STATE_CODE]="DE","PennDel",[STATE_CODE]="NY" Or
[STATE_CODE]="NJ","Atlantic","Other")
Or is it ...."Atlantic", True, "Other")
Perhaps the Switch function example can be followed?
Have a nice day.
Regards This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Thomas Matthews |
last post by:
Hi,
My son is writing a program to move a character. He is
using the numbers on the keypad to indicate the direction
of movement:
7 8 9
4 5 6
1 2 3
Each number has a direction except...
|
by: prafulla |
last post by:
Hi all,
I don't have a copy of C standard at hand and so anyone of you can
help me. I have always wondered how switch statements are so efficient
in jumping to the right case (if any)? Can...
|
by: Scott C. Reynolds |
last post by:
In VB6 you could do a SELECT CASE that would evaluate each case for
truth and execute those statements, such as:
SELECT CASE True
case x > y:
dosomestuff()
case x = 5:
dosomestuff()
case y >...
|
by: rdavis7408 |
last post by:
Hello, I have four textboxes that the user enters the price per gallon
paid at the pump, the mileage per gallon and I would like to then
calculate the cost per gallon and use a switch statement to...
|
by: Macca |
last post by:
Hi,
I have a switch statement that has 5+ case statements. Each of these case
statements copies form one array to another. Rather than doing a separate
try..catch statement for each case...
|
by: priyanka |
last post by:
Hi there,
I had a question. Is there any way of testing a string value in a
switch statement. I have about 50 string values that can be in a string
variable. I tried cheking them with the if...
|
by: Phuff |
last post by:
Hey all, I need some direction help. I have a switch case statement
that is seemingly my only option right now, but its too large and not
easy to maintain the code. Here goes...
I have part...
|
by: |
last post by:
Is it fine to call another method from Switch?
Eg.
Switch (stringVar)
{
case ("a"):
somVar = "whatever";
Another_Method(); //call another method
return;
|
by: Drowningwater |
last post by:
I'm writing a program and I've made a switch statement. I have several quesions:
1. I have a string variable and when I try to use that string variable with the switch function I get a compiling...
|
by: osward |
last post by:
Hello there,
I am using phpnuke 8.0 to build my website, knowing little on php programing.
I am assembling a module for my member which is basically cut and paste existing code section of...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |