Link to home
Start Free TrialLog in
Avatar of DougR_MS
DougR_MS

asked on

Looking for MS Access VBA code to import a table from another .mdb

I am looking for Access VBA code that will import a table from another Access mdb.

After importing the table, rename the table and then add a new column to that table all with VBA code so that it can be automated.

Any help would be great.

Thanks,
Doug
ASKER CERTIFIED SOLUTION
Avatar of InvolveIT
InvolveIT

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of stevbe
stevbe

Public Function ImportTable()

Dim tdf as DAO.TableDef
Dim fld As DAO.Field

'use transferdatabase to pull the table, fill in parameters as appropriate
DoCmd.TransferDatabase ....

'get the table object
Set tdf = CurrentDB.TableDefs("MyTable")

'rename the table object
tdf.Name = "MyNewTable"

'crate a new field object
Set fld = tdf.CreateField("MyField", dbText)

'add the field object to your table object
tdf.Fields.Append fld

'cleanup
Set fld = Nothing
Set tdf = Nothing

End Function

Steve