Hi everyone.
I'm trying to find all the table names from another database file using VB code.
this is what i have so far:
Code:
Function getFileNameOpen(path) As String
Dim f As Object
Dim varFile As Variant
Set f = Application.FileDialog(3)
With f
f.AllowMultiSelect = True
f.Filters.Clear
f.Filters.Add "Access Databases", "*.accdb"
f.Filters.Add "All Files", "*.*"
If f.show = -1 Then
For Each varFile In f.SelectedItems
file = varFile
Next varFile
End If
End With
path = file
End Function
this function will show a browser window so that the user can select a file, and returns the file path.
Code:
Function OpenFile()
Call getFileNameOpen(path)
Dim db As Database
Dim td As TableDef
Database = path
Set db = CurrentDb()
For Each td In db.TableDefs
Debug.Print td.name
Next td
End Function
them I have this function. I need to get all the table names from the selected access file into a list so I can do a for loop after.
I can't figure out how to set the CurrentDb() to the path one.
This code gives me the table names and some other names of stuff which I don't know what they are. But for the current database not the one in the path.
Can anyone help me out here
Thanks so much