PDA

Click to See Complete Forum and Search --> : [RESOLVED] Access - Import External Table


MethadoneBoy
Jun 5th, 2006, 04:58 AM
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 -

DoCmd.SetWarnings(False)

DoCmd.RunCommand <Import function>, <tablename>, <path to external db>...

RobDog888
Jun 5th, 2006, 07:51 AM
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...
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

MethadoneBoy
Jun 5th, 2006, 11:02 AM
That's exactly what I need. Thanks! :)