help

D

Douglas Voltin

Can anyone tell me what the Access VBA code is for deleting, inserting, and
rename column heading in a table?
 
B

Brendan Reynolds

You can execute DDL queries via ADO or DAO, or you can use the DAO or ADOX
object models ...

Public Sub AddRemoveCols()

'execute DDL query via ADO
CurrentProject.Connection.Execute _
"ALTER TABLE tblTest DROP Column TestText", , adCmdText

'execute DDL query via DAO
CurrentDb.Execute _
"ALTER TABLE tblTest ADD Column TestText TEXT (25)", dbFailOnError

'use DAO object model
CurrentDb.TableDefs("tblTest").Fields.Delete ("TestText")

'use ADOX object model
Dim cat As ADOX.Catalog

Set cat = New ADOX.Catalog
Set cat.ActiveConnection = CurrentProject.Connection
cat.Tables("tblTest").Columns.Append "TestText", adVarWChar, 30

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top