View Single Post
  #3  
Old August 11th, 2004, 01:57 AM
Jeff Conrad
external usenet poster
 
Posts: n/a
Default How to create a boolean table field in code?

"Dirk Goldgar" wrote:

Hi Yoda!
Comments below...

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


Ahh haa! that one worked!

SecondField BOOLEAN


Nope, syntax error.
I'm still perplexed why this and dbBoolean do not work.

SecondField YESNO


This one worked as well.
I should have tried dropping the / symbol in my tests.

SecondField LOGICAL


This one also works.
Three out of four, not bad.

It now works just the way I intended and I was able to drop the extra function.
Sweet!

Many thanks Master!
(head bowed)

--
Jeff Conrad
Access Junkie
Bend, Oregon
*282 Days Left*