Link to home
Start Free TrialLog in
Avatar of Moe DeShong
Moe DeShongFlag for United States of America

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
Avatar of Moe DeShong
Moe DeShong
Flag of United States of America image

ASKER

I finally found the right data types to use.  I had so much trouble finding this information I'll post if for anyone else.

      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.
ASKER CERTIFIED SOLUTION
Avatar of Praveen Kumar
Praveen Kumar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
sorry, i thought second post is for some body else, and  i did not read it.
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.