Results 1 to 9 of 9

Thread: Yes/No field in Access SQL create table statement

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2004
    Posts
    541

    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

  2. #2
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    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.
    Tengo mas preguntas que contestas

  3. #3
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    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.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  4. #4
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    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.
    Tengo mas preguntas que contestas

  5. #5
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    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))
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2004
    Posts
    541

    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
    Last edited by stricknyn; Jan 12th, 2007 at 10:31 AM.

  7. #7
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    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.
    Tengo mas preguntas que contestas

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2004
    Posts
    541

    Re: Yes/No field in Access SQL create table statement

    Thanks, I'll try this out

    Strick

  9. #9
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    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".
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width