View Single Post
  #2  
Old August 10th, 2004, 10:34 PM
Dirk Goldgar
external usenet poster
 
Posts: n/a
Default How to create a boolean table field in code?

"Jeff Conrad" wrote in message
...
Hi,

Using Access 97 at the moment, but this project will also be compatible

for 2000+.

I've completed making another Access Add-In and everything works fine, but

there are two tiny issues
I'd like a little feedback on. Second issue will be in another thread.

I'm creating a table in code, but I cannot seem to create a Boolean field

using the "Create Table"
statement. My workaround is to make all the fields except that one on the

first pass. I then use a
second function to create a TableDef on the new table and use a

CreateField statement to make the
Boolean field. This works fine, but what am I missing about using the

Create Table statement?

As a test try this code from the immediate window:

Public Function funcTest()

Dim db As DAO.Database

Set db = CurrentDb

db.Execute "CREATE TABLE tblTest " _
& "(FirstField TEXT, SecondField dbBoolean);"

Set db = Nothing

End Function

I get a syntax error. Instead of dbBoolean I've also tried:
Boolean, Yes/No, True/False, -1/0, Up/Down, etc, but nothing seems to

work.

Is it not possible to make a Boolean field using the Create Table

statement?

Try any of these:

SecondField BIT

SecondField BOOLEAN

SecondField YESNO

SecondField LOGICAL

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup, not by e-mail)