General discussion


How do I copy an Access table with VB?

By Paul ·
I need to be able to copy the structure of an existing Access table in VB, checking to see if a couple of columns exist, if not, creating them, and saving them with a new name. Is this possible programatically?

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

wrong forum

by john.a.wills In reply to How do I copy an Access t ...

put this question in Technical Q & A.

Collapse -


by Paul In reply to wrong forum

Sorry, and I did it again, because the page gave an error.

Collapse -

CopyObject command in VBA

by tim.polito In reply to How do I copy an Access t ...

Presuming you're doing this via VBA code in your Access Database, use the "DoCmd.CopyObject". But to make sure you don't get "system" tables (hidden ones created by Access), use:
Dim t as TableDef
For Each t In CurrentDb.TableDefs
If t.Attributes = 0 Then 'zero = user table
DoCmd.CopyObject sBUTName, "", acTable, t.Name
End If

You can theoretically use this to copy any Access object (table, query, form, report, etc) within a database or to a different database file.

Related Discussions

Related Forums