Hi,
I would like to create a table with 6 fields within an access database(.mdb) thru my application...how do i go about doing this...this is a little urgent..plz help me...
thanx
praveen
I can give you an example using DAO. Most folks seem to use ADO and since DAO's days are, to an extent, numbered, they're probably right to do so. That said: Dim dbMyDB as Database
Dim tdfTable As TableDef
Dim fldField As Field
Set dbMyDB = OpenDatabase("YourDatabasePath"
Set tdfTable = dbMyDB.CreateTableDef("TableName"
Set fldField = tdfTable.CreateField("FieldName", dbText)
tdfTable.Fields.Append fldField 'Repeat from "Set fldField..." for each field
dbMyDB.TableDefs.Append tdfTable
Set fldField = Nothing
Set tdfTable = Nothing
Set dbMyDB = Nothing
When creating your field, check the DataTypeEnum constants in the Object Browser to find appropriate data types (I've set the example to a Text data type).
You will need to add a reference to the Microsoft ADO Ext. 2.x for DLL And Security . This code will create a DB and a table with a couple of columns using ADO. It should get you started anyway.
Private Sub cmdCreateDB_Click()
Dim cat As New ADOX.Catalog
Dim tbl As New Table
Dim sConnection As String
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.