General discussion

Locked

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.

3 total posts (Page 1 of 1)  
| 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 -

OOPS!

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
Next


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

Back to Software Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums