Creating access database table, field type

baha17

Board Regular
Joined
May 12, 2010
Messages
181
Dear All,
I searched on the internet but run out of luck. I am looking for how to write in the script the field data type. Below is my sample code to create table:
Code:
    Set objConnection = New ADODB.Connection
    With objConnection
        .Open strConnectString

                 
        .Execute "CREATE TABLE tblTest ([StaffId] decimal(6), " & _
                 "[StaffName] text(150) WITH Compression, " & _
                 "[StaffOrgPit] text(10) WITH Compression, " & _
                 "[StaffTime] text(10) WITH Compression, " & _
                 "[StaffCurrPit] text(10) WITH Compression, " & _
                 "[StaffPosition] text(10) WITH Compression, " & _
                 "[A-A] text(10) WITH Compression) "
    End With
 
    Set objConnection = Nothing


I learned how to determine “text” ,”number”,”Boolean”,”date”, etc. field data type. But where can I find the reference for all data type. Because I would like to create the table with the first field “AutoNumber”. I tried this did not work:

Code:
     With objConnection
        .Open strConnectString

                 
        .Execute "CREATE TABLE tblTest ([StaffId] AutoGenerate, " & _
                 "[StaffName] text(150) WITH Compression, " & _
                 "[StaffOrgPit] text(10) WITH Compression, " & _
                 "[StaffTime] text(10) WITH Compression, " & _
                 "[StaffCurrPit] text(10) WITH Compression, " & _
                 "[StaffPosition] text(10) WITH Compression, " & _
                 "[A-A] text(10) WITH Compression) "
    End With


Anyone provide me link?

Thank you for the help
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Forum statistics

Threads
1,215,549
Messages
6,125,473
Members
449,233
Latest member
Deardevil

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top