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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

External application closes due to calling code scope 1

Status
Not open for further replies.

Darrylles

Programmer
Feb 7, 2002
1,758
GB
Hi,

I'm producing an app that searches MS Access code modules (forms, reports, modules) and opens a specific module where the search term / word resides.
It works fine if applied to the current database app.

I'm trying to make it more generic so that it can also check a list of other (external) apps.
The problem is, that it opens the external app module ok, but as soon as it exits the local code sub - this closes the external app also.

Any ideas about how to get around this?

The code (which is in a function) is:

Code:
Private Sub Show_Object
    Dim dbs As Database
    Dim rst As Recordset
    Dim strApp As String
    Dim appApp As Access.Application

    Set appApp = CreateObject("access.application")
    strApp = txtApp_Name_Fk                                'Get application path / name.
    appApp.OpenCurrentDatabase strApp
    appApp.Visible = True

    If (Left(txtObj_Container, 5) = "Form_") Then
        appApp.DoCmd.OpenForm Mid(txtObj_Container, 6), acDesign                  'Form.
    Else
        If (Left(txtObj_Container, 7) = "Report_") Then                         'Report.
            appApp.DoCmd.OpenReport Mid(txtObj_Container, 8), acDesign
        Else
            appApp.DoCmd.OpenModule txtObj_Container, acDesign                  'Module.
        End If
    End If

End Sub

As soon as this sub is exited - the external app closes.

Any help / pointers appreciated.

ATB,

Darrylle




Never argue with an idiot, he'll bring you down to his level - then beat you with experience.
 
Move the line:[tt]
Dim appApp As Access.Application[/tt]
to General Declaration (to the top, just below [tt]Option Explicit[/tt]) and try it that way.

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Andrzejek,

So obvious (after the event) - I think I'd gone code-blind.
(Make the object global - so that it persists - globally).

Many thanks.


Darrylle ;-)

Never argue with an idiot, he'll bring you down to his level - then beat you with experience.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top