creating new table in VBA

jcg

Board Regular
Joined
Jul 12, 2002
Messages
156
Can someone provide the VBA code for creating a new table in an access database called "stock1" with fields 1,2 and 3.

Any help would be appreciated.

Jim
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hi,

The simplest way is to execute a CREATE TABLE SQL statement in your code e.g.

Code:
Sub CreateATable()
DoCmd.RunSQL "CREATE TABLE stock (1 TEXT(50), 2 TEXT(50), 3 TEXT (50))"
End Sub

This will create a table with 3 text fields of length 50 characters. To create a numeric field use INT instead of TEXT. There are other data types. Post back if you want something different.
 
Upvote 0

Forum statistics

Threads
1,221,543
Messages
6,160,421
Members
451,644
Latest member
hglymph

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