Sql data type for checkbox?

T

TracyG

Can someone please advice me on what data type to set a sql table field to
accommodate an access checkbox field on a form?
 
M

Martin Walke

Hi Tracy

The Access checkbox is merely a visual representation of the database field.
There isn't an equivalent field in SQL to the logical field in Access - you
have to use 'bit'. You can use int if you want but this obviously takes up
more space.

HTH
Martin
 
T

TracyG

So if the form requires a checkbox, and you use the bit type, then how
should I resolve the issue? I am comfortable with code but can't get my
brain around how I would code this situation. I've tried the bit type, but
the form will not allow the checkbox to be updated - it is like it's
disabled.. any ideas?
 
M

Martin Walke

Humm... not sure on that one Tracy.

When you talking about forms, is this an Access form? It may be that you
have to do some data translation between what Access sees as the data type
for the check box and what you need to send to SQL.

Is the checkbox bound to the field? Try unbinding (?) it to see it that
allows you to access the field on the form. If so, then you'll need to place
some code in the Change event to duplicate what a bound field would do.

Martin
 
B

Brendan Reynolds

A check box can be bound to a bit field, and can be updateable. I just
checked using an ODBC-linked table, the authors table from the pubs sample
database, in which the contact field is a bit field. There has to be
something else about your situation that is preventing you from updating the
field. If you still can't find the problem, try posting a little more
detail. Is this an MDB or an ADP? Does the table have a primary key or other
unique index or constraint? Is the form bound directly to the table, or to a
view or SQL statement?

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
T

Tony Toews

TracyG said:
So if the form requires a checkbox, and you use the bit type, then how
should I resolve the issue? I am comfortable with code but can't get my
brain around how I would code this situation. I've tried the bit type, but
the form will not allow the checkbox to be updated - it is like it's
disabled.. any ideas?

Is this a triple state check box? If so you'd need to ensure it's an
int field as that requires null, true or false. Which isn't support
by either Access yes/no or SQL Server bit fields.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
 
Top