Link to home
Start Free TrialLog in
Avatar of gbnorton
gbnortonFlag for United States of America

asked on

Open a form in another database problem

I use this code to open a form in another database:

Private Sub btnOpenPlatinumTraveler_Click()
    Dim objACC As New Access.Application
   
    Set objACC = GetObject("T:\Diode Travelers Application\Source\DiodePlatinumDiffusionTravelerApplication.accdb")
    objACC.DoCmd.OpenForm ("Switchboard"), acNormal
'    objACC.Quit
'    Set objACC = Nothing
End Sub

But it opens the form and closes it immediately.  I can use a breakpoint at End Sub to see the form is open.  And I can use it normally.  

What needs to be done to keep the form open?
Thanks,
Brooks
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
this is becaue the objACC goes out of scope, and hence closes the application (and the form).

please define the variable objAcc on your form level, and it shall work.

and you might then check if objAcc is already set , and reuse it if you are to open several forms of that same other database ...
Avatar of gbnorton

ASKER

Thanks Capricorn
Please look for my follow up question about having the form open up on top...
Brooks