Reputation: 6353
I have an access DB with around 20 tables. I'd like to create a form that has a dropdown menu of all my tables in it. When a table is selected, Im trying to get the subform to reflect the information from those tables.
Basically, instead of having to click and open each table, look through them within a form. Is this possible?
Is this possible?
Upvotes: 1
Views: 678
Reputation: 49049
You could call this sub to populate your dropdown menu:
Private Sub Add_Tables_To_DropdownMenu()
Dim T As TableDef
For Each T In CurrentDb.TableDefs
If (Left(T.Name, 4) <> "USys") And (T.Attributes = 0) Then
Dropdownmenu0.AddItem T.Name
End If
Next
End Sub
Then you can set an event on change of the dropdown menu, and update the SourceObject of your subform based on the value selected:
Private Sub Dropdownmenu0_AfterUpdate()
Subform1.SourceObject = "Table." & Dropdownmenu0.Value
End Sub
Upvotes: 2