Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

VBA to import table from multiple databases

$
0
0
dear all,
I'm newly using macro in Access 2010 and I have code snippet as below:

Code:

Dim SQL As String

SQL = "INSERT INTO attCombiAttach_ROP_RAW "
SQL = SQL & "SELECT * "
SQL = SQL & " FROM attCombiAttach_ROP_RAW" & " " & "IN 'G:\PATH\SGDPS1A_20130301.mdb'; "

CurrentDb.Execute SQL

it successfully runs append query between 2 tables (same name, attCombiAttach_ROP_RAW) and 2 databases.

my question is, could you guys do some change in that code so that it can import table from more than one database at the same time?
(depend on how many databases within that PATH)
for example, there are:
G:\PATH\SGDPS1A_20130302.mdb
G:\PATH\SGDPS1A_20130303.mdb
G:\PATH\SGDPS1A_20130304.mdb


what command should I add?
to read the number of .mdb files then use this numbers as a loop in string query.
Code:

SQL = SQL & " FROM attCombiAttach_ROP_RAW" & " " & "IN 'G:\PATH\SGDPS1A_[loopingdate].mdb'; "
your advice will be highly appreciate.
thank's.

Viewing all articles
Browse latest Browse all 13329

Trending Articles