I am trying to populate a ListBox with the names of the tables from another database. I have the following function which loops the table names from the database I want. The function is caleld on Form Load and passed into the ListBox but the List Box is empty
NOTE: The message box in the function does display the table names when called from the form. I just cannot get the list box to populate.
NOTE: The message box in the function does display the table names when called from the form. I just cannot get the list box to populate.
Code:
Public Function ListTables()
Dim db As Database
Dim i As Integer
Dim s As String
Dim tdefs As TableDefs, tdef As TableDef
Set db = DBEngine.OpenDatabase("C:\MyPath\Analyzed Tables.mdb")
For i = 0 To db.TableDefs.count - 1
s = db.TableDefs(i).Name
ListTables = s
'MsgBox s
Next i
End Function
Code:
Private Sub Form_Load()
List1.RowSource = ListTables
End Sub