Quick warning about MS Access data types

The other day, I discovered a minor inconvenience in the way MS Access handles the “Yes/No” (or boolean) data type.

You should be aware, when working with MS Access, that any “Yes/No” field in your table can only accept boolean true and boolean false (or “true” and “false”, “yes” and “no”, 1 and 0, etc.). It will not accept NULL.

Standard programming practice is, when there is not a “default” value for a field, to insert NULL if the user does not explicitly declare a value. Unfortunately, the fact that Access throws an error if you try to insert NULL into a “Yes/No” field really puts a damper on that logic.

As the title says, this is just a quick warning for people that may be using MS Access for their databases. I’m not sure if the same is true for MS SQL or not, but it’s obviously a non-factor with MySQL, since MySQL doesn’t offer a boolean data type.

Did you like this post? Get monthly summary of our new tutorials, posts and tips to your inbox!

One Response

  • ramz

    boolean of ms access is not a bit. its an integer type.

Post Your Comment

Your email address will not be published.