Moe DeShong
asked on
Create fields in Access with vb 2005
I use the following sql to create a table and insert fields:
fSql = "CREATE TABLE Resources (txtLastName Text(50), txtFirstName Text(50), txtPhoneMobil Text(14), " _
& "txtPhoneHome Text(14), txtDepartment Text(50), txtPosition Text(50), txtNotes Memo)"
This works fine except when I try to add AutoNumber or Yes/no fields then I get an error. What is the correct syntax to add "AutoNumber" and "Yes/No" field types? What is the syntax to add a field to an existing table. Thanks
fSql = "CREATE TABLE Resources (txtLastName Text(50), txtFirstName Text(50), txtPhoneMobil Text(14), " _
& "txtPhoneHome Text(14), txtDepartment Text(50), txtPosition Text(50), txtNotes Memo)"
This works fine except when I try to add AutoNumber or Yes/no fields then I get an error. What is the correct syntax to add "AutoNumber" and "Yes/No" field types? What is the syntax to add a field to an existing table. Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
sorry, i thought second post is for some body else, and i did not read it.
ASKER
Thanks for the response. I did finally find the info after a long search. It's one of those topics you have to know exactly what to search for.
yes, i agree. and it is very importatnt to know these datatypes.
thanks for points.
thanks for points.
ASKER
MyText TEXT(50),
MyMemo MEMO,
MyByte Byte,
MyInteger Integer,
MyLong Long,
MyAutoNumber COUNTER,
MySingle Single,
MyDouble Double,
MyCurrency Currency,
MyReplicaID GUID,
MyDateTime DATETIME,
MyYesNo YESNO,
MyOleObject LONGBINARY,
MyBinary BINARY(50)
Syntax sql = "Create Table Table1(field1 TEXT(50), field2 Counter NOT NULL PRIMARY KEY, etc...)
I don't know if all these are actually useable in Access but the ones I need have worked fine in VB 2005.