INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

External application closes due to calling code scope

External application closes due to calling code scope

(OP)
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 --> vb

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.

RE: External application closes due to calling code scope

Move the line:
Dim appApp As Access.Application

to General Declaration (to the top, just below Option Explicit) 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.

RE: External application closes due to calling code scope

(OP)
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 winky smile

Never argue with an idiot, he'll bring you down to his level - then beat you with experience.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close