[RESOLVED] Access - Import External Table
Hi guys,
Is there any example of VBA code that will import a table from an external database into the current database (without using import/export specs)?
I'm thinking something along the lines of -
VB Code:
DoCmd.SetWarnings(False)
DoCmd.RunCommand <Import function>, <tablename>, <path to external db>...
Re: Access - Import External Table
You can perform an "INSERT INTO blah SELECT * FROM blah..." sql statement but your table will need to exist first. If your looking for the table creation too then you can use a function like so...
VB Code:
Public Sub ImportTable()
Application.DoCmd.SetWarnings False
Application.DoCmd.TransferDatabase acImport, "Microsoft Access", "D:\DB2ImportFrom.mdb", acTable, "Table1", "ImportedTableName", False
'OR
Application.DoCmd.CopyObject "DestinationDatabase", "NewName", acTable, "SourceObjectName"
Application.DoCmd.SetWarnings True
End Sub
Re: Access - Import External Table
That's exactly what I need. Thanks! :)