I've spent several hours searching the internet but haven't found a proper solution yet.
I have a few hundred access databases all with the same tables and structure, and want to import all the data in a 'mother' database (which i created with the same tables and structure).
I am using a sub that feeds a string to another public sub as follows:
Where I would like my sub AppendAll to do the job:
I have a few hundred access databases all with the same tables and structure, and want to import all the data in a 'mother' database (which i created with the same tables and structure).
I am using a sub that feeds a string to another public sub as follows:
Code:
Private Sub cmdImport_Click()
Dim strFolder As String 'source folder path for import
Dim strFile As String 'individual file path
strFolder = GetFolder(Environ$("USERPROFILE") & "\Documenti\")
If Len(strFolder) <= 1 Then Exit Sub
If Right(strFolder, 1) <> "\" Then strFolder = strFolder & "\" 'adds trailing backslash
strFile = Dir$(strFolder & "*.accde")
Do While Len(strFile) > 0
Call AppendAll(strFolder & strFile, "tblRispCheckLocal", "tblRispCheck")
strFile = Dir$()
Loop
End Sub
Where I would like my sub AppendAll to do the job:
Code:
Public Sub AppendAll(strDBName As String, strTableName As String, strNewTableName As String)
Dim MySQL As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = OpenDatabase(strDBName)
Set rs = db.OpenRecordset(strNewTableName)
MySQL = "INSERT INTO " & strTableName & _
"???" 'should I use recordsets? I failed to use SQL to access data on other files, but if there's a way it would be optimal!
rs.Close
Set rs = Nothing
End Sub