Solved

correct sql statement

Posted on 2006-10-30
3
444 Views
Last Modified: 2011-08-18
I am trying to select all records from a column in Microsoft Access.  The column is checkbox column with Yes/No as the data type.  Is this the correct way to query a checked box in Access using sql statements?

        esql = "Select * from " & c & " Where Rearrested = 1"
0
Comment
Question by:al4629740
3 Comments
 
LVL 20

Assisted Solution

by:hes
hes earned 100 total points
ID: 17835235
Just for readability I like to use
esql = "Select * from " & c & " Where Rearrested =" & vbTrue
0
 
LVL 5

Expert Comment

by:daohailam
ID: 17835264
The query should be like this:

SELECT <columns|*> FROM <table> WHERE <column> = <smth> ...
0
 
LVL 9

Accepted Solution

by:
smidgie82 earned 400 total points
ID: 17835272
Hi hes,

My experience (with access 2003) is that yes/no fields will compare correctly against TRUE and FALSE, but not 1 and 0.  So, to work correctly, change your query to
esql = "SELECT * FROM " & c & "WHERE Rearrested = TRUE".

If you're doing it from VBA, this is equivalent to hes's solution.  But this method will also work if, say, used from Java via JDBC.  Or Access's builtin SQL editor.

Cheers!
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This video teaches viewers about errors in exception handling.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

831 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