473,804 Members | 3,190 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using switch instead of case to specify order

Hi everyone, I'm having a brain freeze today so if the answer is a
misplacced comma or a missing command, I would be happy.

What I want to do is use access to return results via an .asp page.

<coff> is the table
<postion> is the column
I do not want the results in alpha order, but the order specified
below, but I keep getting a syntax error: 'Syntax error (missing
operator) in query expression '

Here is the massive statement that doesn't want to fly. ;-/

SELECT * FROM coff WHERE (CHNAME = 'nwoc')

Switch([Position]="President" ,1,[Position]="Vice
President",2,[Position]="Secretary" ,3,[position]="Treasurer" ,4,[postion]="Secretary
/ Treasurer", 5)

Thanks in advance...
Nov 12 '05 #1
2 5060
to**@ascnet.org (Tom Morgan) wrote in
news:78******** *************** ***@posting.goo gle.com:
Hi everyone, I'm having a brain freeze today so if the answer is a
misplacced comma or a missing command, I would be happy.

What I want to do is use access to return results via an .asp
page.

<coff> is the table
<postion> is the column
I do not want the results in alpha order, but the order specified
below, but I keep getting a syntax error: 'Syntax error (missing
operator) in query expression '

Here is the massive statement that doesn't want to fly. ;-/

SELECT * FROM coff WHERE (CHNAME = 'nwoc')

Switch([Position]="President" ,1,[Position]="Vice
President",2,[Position]="Secretary" ,3,[position]="Treasurer" ,4, [pos tion]="Secretary / Treasurer", 5)


Er, where are you using the Switch() statement? Does this work:

SELECT coff.*, Switch([Position]="President" ,1,[Position]="Vice
President",2,[Position]="Secretary" ,3,[position]="Treasurer" ,4,
[position]="Secretary / Treasurer", 5) As PositionCode
FROM coff
WHERE (coff.CHNAME = 'nwoc')

Or, you might use a lookup table that maps the positions to the code
number.

Or, if there's a 1:1 relationship between position and code number,
then store only the number and have the position stored in the
lookup table.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 12 '05 #2
DFS
Tom,

Your Switch seems to be disconnected from your SELECT statement. Try:

SELECT *,
Switch([Position]="President" ,1,
[Position]="Vice President",2,
[Position]="Secretary" ,3,
[Position]="Treasurer" ,4,
[Position]="Secretary / Treasurer", 5) AS JobCode
FROM coff
WHERE CHNAME = 'nwoc'
ORDER BY
Switch([Position]="President" ,1,
[Position]="Vice President",2,
[Position]="Secretary" ,3,
[Position]="Treasurer" ,4,
[Position]="Secretary / Treasurer", 5)

"Tom Morgan" <to**@ascnet.or g> wrote in message
news:78******** *************** ***@posting.goo gle.com...
Hi everyone, I'm having a brain freeze today so if the answer is a
misplacced comma or a missing command, I would be happy.

What I want to do is use access to return results via an .asp page.

<coff> is the table
<postion> is the column
I do not want the results in alpha order, but the order specified
below, but I keep getting a syntax error: 'Syntax error (missing
operator) in query expression '

Here is the massive statement that doesn't want to fly. ;-/

SELECT * FROM coff WHERE (CHNAME = 'nwoc')

Switch([Position]="President" ,1,[Position]="Vice
President",2,[Position]="Secretary" ,3,[position]="Treasurer" ,4,[postion]="Se
cretary / Treasurer", 5)

Thanks in advance...

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

35
8364
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 for '5'. So in his switch statement, he omits a case for '5':
11
6607
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on where the job is running, the job runs sucessfully, PDF files got generated, everything is good. If I scheduled the job to run at the time that I am not logged into the server, Access is not able to print to the printer. The error is pretty...
19
676
by: Kamilche | last post by:
I have looked at many object-oriented programming frameworks out there for C. Though the ideas presented are intriguing, and I've used some of them in my own work, they all suffered some drawback or another. I have created a new method of doing OOP with C, something that fits my needs particularly well. I haven't encountered anything else like it, so I'm tossing it out to the Internet for comment. ...
5
10156
by: Neil Zanella | last post by:
Hello, Unlike in pre-C99 versions of C where variables can only be defined at the beginning of blocks, C99 allows variables to be defined in arbitrary places inside blocks. However, gcc 3.2.2 seems to reveal that there are still places where this is illegal. For instance, consider the following code snippet. int main(void) { int i = 0;
7
3519
by: Peter Jansson | last post by:
Dear group, I have been struggling to get a simple program for inserting and extracting std::tm objects to/from streams to work. The code below tries to read a std::tm object from a std::istringstream but fails to do so, could anybody see what is wrong with the code? (Output follows the code.) I fear that I have not completely grasped how the time_getXXX methods should be used in the operator<< ? With best regards,
11
9331
by: David H. Cook | last post by:
Hi - I just installed the express-edition of DB2 server (on a Win-XP machine), and then I setup a client JDBC driver to access it. The query is a simple 'select * from EMPLOYEE' against their SAMPLE database. (This query works fine from within 'Control Center'...there is data in this table, etc.)
21
7738
by: aaron80v | last post by:
Hi, A simple question: In ANSI-C, how to specify a string as the expression for switch statement. eg switch (mystr) { case "ABC" : bleh... break;
8
8055
by: Roland Hall | last post by:
In Access you use "*" + + "*", + can be replaced with & Calling a parameterized query in Access requires % be used in place of *, however, all that I have read show dynamic SQL passed to Access: WHERE LIKE '" & ASPvar & "' % ORDER BY ... However, my call is similar to: conn.qMyLookup strVar, rs
0
9706
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10578
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10332
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10321
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10077
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9152
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7620
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6853
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.