How to create a yes/no checkbox column in ACCESS 2010

I am adding a yes/no column to an existing table, but the below does not work.  I thought yes/no columns were Bytes, but it is failing.

CurrentDb.Execute "ALTER TABLE tblPerson1 ADD COLUMN AAPerson Byte "
Sandra SmithRetiredAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NorieVBA ExpertCommented:
Aren't they boolean?
0
NorieVBA ExpertCommented:
Actually just checked, though a Yes/No is boolean to add such a column with SQL you use BIT.

For example.

ALTER TABLE tblPerson1
    ADD COLUMN AAPerson BIT  DEFAULT 0   NOT NULL
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sandra SmithRetiredAuthor Commented:
Thank you, thought it was Byte and never considered it was Bit.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Nick67Commented:
@Norie has it right
yes/no fields are Booleans in Access, bits in SQL Server, but the syntax for adding via SQL is indeed bit

CurrentDb.Execute "ALTER TABLE tblPerson1 ADD COLUMN AAPerson bit"

This gets you a yes/no field in your table.
Bytes are 0 - 255


Byte, Integer and Long IntegerIntegers in Access come in 1, 2 and 4 byte varieties. The single byte number is named Byte (Range 0-255), the two-byte number is named Integer (-32768 to 32767) and then there is the Long Integer (-2 billion to 2 billion).

If I might ask: why would you do something like that through code rather than the GUI?  It's a one-off operation.  Why code it?
0
Sandra SmithRetiredAuthor Commented:
this is a import process from old database to a new, restructured one and I do not want to have to all this manually each time fresh production data is brought in to test.  The two are structured so differently, I am making an import process to do all the clean up automatically, this is not a one-off operation.  If I could do this another way, I would, but with the time constraints, this is the fastest approach and is working without too many glitches so far.
0
Nick67Commented:
Good enough.
I hadn't thought of ETL applications of DDL/Alter Table code

Thanks!

Nick67
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.