Yes/No field in Access SQL create table statement
Hello all,
Anyone know the syntax to create a yes/no field in a SQL create table statement (Not using the designer, SQL only) in ms access?
ie something like:
CREATE TABLE test (FIELD1 TEXT(35), FIELD2 YES/NO))
The text field is correct, but I don't know the datatype to create the yes/field. FYI, I've tried boolean and bit; boolean doesn't work, and bit creates the field, but as a text box instead of a checkbox. This is in MS Access
Thanks in advance!
Strick
Re: Yes/No field in Access SQL create table statement
Use Boolean for the data type. I don't know why Access calls it Yes/No in table design, but the data type is boolean.
Re: Yes/No field in Access SQL create table statement
Because you can set it to show (in Access) Yes/No, True/False or On/Off - all of which are ways to represent a boolean value.
Re: Yes/No field in Access SQL create table statement
I know, but calling it Yes/No is a poor idea and leads to confusion like this. You could also use numeric values, -1 & 0 (I think, never keep them straight).
The only reason I can think why MS did this is to design Access for dopes who can't tell between "Yes" and "True"
Me: Jessica Alba, would you like to spend the night with me?
Jessica: Yes
Me:Jessica Alba, would you like to spend the night with me?
Jessica: True
I've never asked Jessica Alba this question and gotten a different answer. So there.
Re: Yes/No field in Access SQL create table statement
you can use something like this
Code:
CREATE TABLE test (FIELD1 TEXT(35), FIELD2 BIT))
Re: Yes/No field in Access SQL create table statement
Thanks guys,
I've already tried it as bit. Problem is, it will create the field but it will create it as a textbox instead of a checkbox. I needed it created as a check box.
Also, boolean doesn't work.
Thanks for all your help.
Strick
Re: Yes/No field in Access SQL create table statement
Huh. Apparently Access calls it YesNo, no slash. To see the table you'll have to refresh the database window. This might help.
Re: Yes/No field in Access SQL create table statement
Thanks, I'll try this out
Strick
Re: Yes/No field in Access SQL create table statement
Quote:
Originally Posted by salvelinus
I know, but calling it Yes/No is a poor idea and leads to confusion like this. You could also use numeric values, -1 & 0 (I think, never keep them straight).
The only reason I can think why MS did this is to design Access for dopes who can't tell between "Yes" and "True"
Designed by the same guy who invented the ADO Data Control, so that if you can drag a control to a form you can be a "database front end developer".