I have this code (from MSKB) tied to a combo box on a form.
Unfortunately, I want it to refer to another databases objects and not the current one. Can anyone tell me how to revise this code to call the objects in another database? Thanks for any assistance!
Unfortunately, I want it to refer to another databases objects and not the current one. Can anyone tell me how to revise this code to call the objects in another database? Thanks for any assistance!
Code:
Dim accObject As Access.AccessObject
'Fill with Tables
For Each accObject In CurrentData.AllTables
Me.Objects.AddItem accObject.Name & ";TABLE"
Next
'If currently opened file is an Access database (mdb), then fill
'with queries.
'Otherwise, if it is an Access project (adp), fill with views,
'stored procedures, database diagrams, and functions.
If CurrentProject.ProjectType = acMDB Then
For Each accObject In CurrentData.AllQueries
Me.Objects.AddItem accObject.Name & ";QUERY"
Next
Else
For Each accObject In CurrentData.AllViews
Me.Objects.AddItem accObject.Name & ";VIEW"
Next
For Each accObject In CurrentData.AllStoredProcedures
Me.Objects.AddItem accObject.Name & ";PROCEDURE"
Next
For Each accObject In CurrentData.AllDatabaseDiagrams
Me.Objects.AddItem accObject.Name & ";DIAGRAM"
Next
For Each accObject In CurrentData.AllFunctions
Me.Objects.AddItem accObject.Name & ";FUNCTION"
Next
End If
'Fill list with forms.
For Each accObject In CurrentProject.AllForms
Me.Objects.AddItem accObject.Name & ";FORM"
Next
'Fill list with reports.
For Each accObject In CurrentProject.AllReports
Me.Objects.AddItem accObject.Name & ";REPORT"
Next
'Fill list with data access pages.
For Each accObject In CurrentProject.AllDataAccessPages
Me.Objects.AddItem accObject.Name & ";PAGE"
Next
'Fill list with macros.
For Each accObject In CurrentProject.AllMacros
Me.Objects.AddItem accObject.Name & ";MACRO"
Next
'Fill list with modules.
For Each accObject In CurrentProject.AllModules
Me.Objects.AddItem accObject.Name & ";MODULE"
Next