Solved

SQL for yes/no type data

Posted on 2000-02-20
8
646 Views
Last Modified: 2012-08-14
I have an access table with yes/no data type.  Each of the fields in the table has a box, which can be checked (presumably meaning "yes") or unchecked (i. e. empty presumably meaning "no").  An attempt to query this data table produced the following error.  I guess there is another way to form queries with this data type.  Please help.

SQL Statement:
SELECT * FROM tblLinkNames WHERE P6 = 'Yes'

Error:
Microsoft OLE DB Provider for ODBC Drivers error '80040e21'

The request properties can not be supported by this ODBC Driver.

/infopages/search_results.asp, line 44
0
Comment
Question by:Venkatagiri
8 Comments
 

Expert Comment

by:toesable
ID: 2541160
SELECT * FROM tblLinkNames WHERE [P6] = Yes

I believe, and I could be wrong if you really are going through ODBC, that the only problem with your SQL is that you have apostrophies around yes.  The above works in my database.

Maybe someone else will have an idea if this doesn't work.
0
 
LVL 6

Expert Comment

by:Marine
ID: 2541164
This works try it.
SELECT * FROM tblLinkNames WHERE P6 = Yes
0
 
LVL 2

Expert Comment

by:Bangerter
ID: 2541268
one other option is to use the numeric value for yes which would be -1 or no would be 0
0
 
LVL 12

Accepted Solution

by:
Trygve earned 100 total points
ID: 2541324
Bangerter: Since this is ASP: True = 1, False = 0

The best way to search for boolean values (and keeping the expression compatible with Access AND ASP environment) is to use 0 for False and <> 0 for True

Searching for True:
SELECT * FROM tblLinkNames WHERE [P6] <> 0

Searching for False:
SELECT * FROM tblLinkNames WHERE [P6] = 0

Also: Yes is never an option since it is just one of the possible formats for showing boolean fields in forms and reports (it is supported by Access though). The "textual" alternatives are True and False.

SELECT * FROM tblLinkNames WHERE [P6] = True
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Expert Comment

by:toesable
ID: 2541333
Absolutely correct Trvqve.  toe
0
 
LVL 12

Expert Comment

by:Trygve
ID: 2541361
Actually the name is Trygve, but the underline used for URLs here at EE makes it easy to do mistakes. I have posted a suggestion to change the underline format so that it does not "messes with our logins" :-)) http://www.experts-exchange.com/bin/Q.10298381
0
 

Author Comment

by:Venkatagiri
ID: 2543814
Thanks for all your comments.  The solution offered by Trygve was the most general and it worked for me.  Some of the other solutions offered would also probably work in this particular situation.  Thanks for your help.  I have allocated the points to Trygve.
0
 
LVL 12

Expert Comment

by:Trygve
ID: 2545047
Thank you!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now