Link to home
Start Free TrialLog in
Avatar of Sandra Smith
Sandra SmithFlag for United States of America

asked on

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 "
Avatar of Norie
Norie

Aren't they boolean?
ASKER CERTIFIED SOLUTION
Avatar of Norie
Norie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sandra Smith

ASKER

Thank you, thought it was Byte and never considered it was Bit.
@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?
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.
Good enough.
I hadn't thought of ETL applications of DDL/Alter Table code

Thanks!

Nick67