I'm using Access 2003 with a VB 2005 front end.
I have this code written to dynamically create a table in an access database:
The above code works.Code:DBCommand.CommandText = "CREATE TABLE Item(" & _ "ItemID Varchar(255) NOT NULL UNIQUE," & _ "ItemName Varchar(255) NOT NULL," & _ "ItemDesc Varchar(255) NOT NULL," & _ "ItemCat Varchar(255) NOT NULL," & _ "ItemType Varchar(255) NOT NULL," & _ "ItemQty Integer NOT NULL," & _ "ItemWarn Integer NOT NULL," & _ "ItemVendor Varchar(255) NOT NULL," & _ "ItemVisible Varchar(255) DEFAULT 'Yes' NOT NULL," & _ "ItemUnit Varchar(255) NOT NULL," & _ "ItemOrdered Varchar(255) DEFAULT 'No' NOT NULL," & _ "PRIMARY KEY (ItemID));" DBCommand.ExecuteNonQuery()
However, for obvious reasons, I wouldn't want a field such as "ItemVisible" or "ItemOrdered" to be a string, I'd prefer to use a yes/no field. They're only varchar at the moment because I can't make this command work any other way.
So, this brings me to my question: What does the command need to be in order to dynamically create a yes/no (boolean) field in an Access DB?
Also, what does the command have to be to dynamically create an autonumber field in the database?
I've looked quite a bit on the internet, and I can't find any examples of this. And my book from class only has some basic examples using text/number fields. Any help would be appreciated. Thanks.


Reply With Quote
