reference to the right instance of Access

  • Thread starter Thread starter Lauro
  • Start date Start date
L

Lauro

I need to get a reference to an already open instance of Access if it
is running or open it if not.

I'm using GetObject.

If no other instances of Access are open I have no problem. But I
have no guarantee to point to the rigth one if the user has already
opened one.

I found an half solution with a strange behavior:

Set oAccApp = GetObject(MyFileName, "Access.Application")
oAccApp.Visible = True

works fine (it open a new instance if it is not open or open and
"magically" merge it with the old one if already exists) if I don't
have a StartUp Form.

if I have a StartUp form, I tried to use:

Set oAccApp = GetObject(MyFileName, "Access.Application")
oAccApp.Visible = True
oAccApp.DoCmd.Close acForm, "Welcome Form"

But I get a run time error 2455 .

If I delete
oAccApp.Visible = True
I get multiple instances of my database.

Why?

Any Suggestions?

Thanks Lauro
 
If I delete
oAccApp.Visible = True
I get multiple instances of my database.

If it is not visible, it does not register itself
in the list of open objects. Don't know why.
But I get a run time error 2455 .

What's that?

(david)
 
Back
Top