Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reference Objects in another Database?

Status
Not open for further replies.

AppStaff

Programmer
Sep 21, 2002
146
0
0
US
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!

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
 
Look for "Run Method" and it's example in VBA help

________________________________________________________
Zameer Abdulla
Help to find Missing people
Do not cut down the tree that gives you shade.
 
Thanks for responding. I'm confused by this method however. This seems to give me a means to call a procedure to run in another database but I want to run the procedure in the current database but refer to the objects in another one. Does this do what I need? If so I'd appreciate code to demonstrate. I'm not an expert with vba and have never used this method before.
 
try thread702-1125318 may help you.

You can refer another db by
Tools | Reference dialog browse button.

________________________________________________________
Zameer Abdulla
Help to find Missing people
Do not cut down the tree that gives you shade.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top