To get an introduction to getting better answers please read faq222-2244 fully.
For this question we may need rather a lot more info, as we don't know what tools you are using to manipulate your DB!
If you're using JetSQL then look up the ALTER TABLE command, using the ADD method to the COLUMN collection.
If you're using ADOX then look at the Append method for the Columns collection
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'If we're supposed to work in Hex, why have we only got A fingers?'
Did you try ADOX (as suggested in my first reply) ?
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'If we're supposed to work in Hex, why have we only got A fingers?'
Yes I did. Following ADOX code (from Dimandja) appends a field to a new table. Is there a way to change this to add a field to an existing table?
Thanks
Dim Cn As ADODB.Connection, Cat As ADOX.Catalog, _
objTable As ADOX.Table
Set Cn = New ADODB.Connection
Set Cat = New ADOX.Catalog
Set objTable = New ADOX.Table
'Open the connection
Cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=biblio.mdb"
'Open the Catalog
Set Cat.ActiveConnection = Cn
'Create the table
objTable.Name = "Test_Table"
'Create and Append a new field to the "Test_Table"
'Columns Collection
objTable.Columns.Append "PrimaryKey_Field", adInteger
'Create and Append a new key. Note that we are merely passing
'the "PimaryKey_Field" column as the source of the primary key.
'Thi snew Key will be Appended to the Keys Collection of
'"Test_Table"
objTable.Keys.Append "PrimaryKey", adKeyPrimary, _
"PrimaryKey_Field"
'Append the newly created table to the Tables Collection
Cat.Tables.Append objTable
' clean up objects
Set objKey = Nothing
Set objTable = Nothing
Set Cat = Nothing
Cn.Close
Set Cn = Nothing
End Sub
As johnwm stated, you need to use the Append method for the Columns collection. Leave the Tables collection alone (well, at least leave the Append method alone)...
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.