I figured out how to import a table using VBA like so:
This was just a test to see if I could get an import to work. My problem is that I have a lot of .mdb/.accdb files with similar tables that I need to add into one larger database and these similar tables could have different names in different folders. For example, a file named db1.mdb has a table named tbl. Another file named db2.mdb has a table with all of the same fields, but its called tabX. Furthermore, db2.mdb could even contain a second table that I need to import.
Sorry if that explanation was unnecessarily long. I'm only trying to be clear.
My question is:
Is there a way to simply import all the tables from an access database without knowing any table names using VBA?
Thank you for your time. Any help is greatly appreciated.
Code:
Private Sub Command0_Click()
Dim dr As String
dr = Dir("F:\SomeFolder\*.mdb", vbDirectory)
DoCmd.TransferDatabase acImport, "Microsoft Access", "F:\SomeFolder\" & dr, acTable, "Table", "Table2"
End Sub
This was just a test to see if I could get an import to work. My problem is that I have a lot of .mdb/.accdb files with similar tables that I need to add into one larger database and these similar tables could have different names in different folders. For example, a file named db1.mdb has a table named tbl. Another file named db2.mdb has a table with all of the same fields, but its called tabX. Furthermore, db2.mdb could even contain a second table that I need to import.
Sorry if that explanation was unnecessarily long. I'm only trying to be clear.
My question is:
Is there a way to simply import all the tables from an access database without knowing any table names using VBA?
Thank you for your time. Any help is greatly appreciated.