Click here to Skip to main content
13,089,433 members (59,239 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hey guys

Do you have any ideas for creating a column (data type = bool -> show as check box) in Access by using SQl? I'm wrinting a tool in MFC, C++ and I need to safe some values in a database.

I allready tried this, which I found somewhere in the internet:
ALTER TABLE table_name ADD COLUMN column_name BIT

That doesn't work...

..I hope someone can help me.

Posted 11-Feb-13 4:08am
Maciej Los 11-Feb-13 10:20am
What you mean: "That doesn't work"?
epanjohura 11-Feb-13 10:32am
that means: I only get a created field (type = text) with the content 0 or 1, but I want to have "real" check boxes, where I can *check* values.
you know what I mean?
Maciej Los 12-Feb-13 8:30am
Now i understand.
epanjohura 12-Feb-13 8:26am
is there anybody who can help to solve this problem?
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

ALTER TABLE mytable ADD mynewcolumn YESNO
epanjohura 11-Feb-13 10:15am
thank you for your answer, but that doesn't work. it creates the same as the code I tried.
According to, YESNO is the default datatype for your question.
Maybe your problem have to do with your sql command, because True is equal to -1 and False is equal to 0.
Can you send more details about the problem or try to explain in a different way ?
epanjohura 11-Feb-13 10:30am
well, actually I want to have real check boxes in my access database, you know what I mean? with this YESNO commant I get only 0/1 as text in the created field
When you open your mdb file using the access, you want to see a check box instead of a 0/1 values?
epanjohura 11-Feb-13 10:36am
yes, exactly :)
Please check if this is applied to your question:
epanjohura 11-Feb-13 11:14am
That's not what I'm looking for. This link shows an instruction how to do it manually after opening the database in Access in another view.
I want to do it automatically by just executing a command.
I can't help you. Additionally i don't event think that is possible.
epanjohura 11-Feb-13 11:28am
well, thank you anyway
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Storing data is not the same as presenting data. So, your field is still "bit" type and can store values: true/false, enabled/disabled, Yes/No.

I know, there are some differences between programming windows forms and MFC programming[^], but it changes nothing in our discuss. Remember, only application's user interface (UI) is responsible for data presentation layer and control. Embeded mechanisms route user input commands (checked selections, button clicks) to internal functions that may update the application's data. UI controls (windows, edit boxes, checkboxes, etc.) are responsible for displaying the application's data after each update.
epanjohura 12-Feb-13 10:47am
that's not what I'm searching for..
Maciej Los 12-Feb-13 10:49am
epanjohura 12-Feb-13 10:50am
but thank you for trying

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170813.1 | Last Updated 12 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100