Issue with opening one database from another (1 Viewer)

Metric

Registered User.
Local time
Today, 15:21
Joined
Sep 14, 2019
Messages
26
Hello,

I have two databases and I'd like a button in one to be able to open the other. I've written this code:

Call Shell ("""C:\Program Files\Microsoft Office\Office16\MSACCESS.EXE"" ""C:Users\me\myfilename.accdb")

This works like a charm to actually open the database but with one issue - the newly opened file is underneath the existing one and therefore not obviously visible to the user. Is there a way to force it to open over top, like a pop up window?

Thanks!
 

Isaac

Lifelong Learner
Local time
Today, 15:21
Joined
Mar 14, 2017
Messages
8,738
Have you considered using Access automation?

Code:
dim accessapp as object

set accessapp=createobject("access.application")

accessapp.opencurrentdatabase("path to database")

You might be able to use AppActivate to activate it, also, check out the WindowStyle argument of Shell
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 06:21
Joined
May 7, 2009
Messages
19,169
use code in post#2:


Code:
Option Explicit

Dim oAccess As Object

Private Sub yourButton_Click()
    Set oAccess = CreateObject("Access.Application")
    oAccess.OpenCurrentDatabase("C:\users\me\yourDatabaseHere.accdb")
End Sub
 

Metric

Registered User.
Local time
Today, 15:21
Joined
Sep 14, 2019
Messages
26
Have you considered using Access automation?

Code:
dim accessapp as object

set accessapp=createobject("access.application")

accessapp.opencurrentdatabase("path to database")

You might be able to use AppActivate to activate it, also, check out the WindowStyle argument of Shell

The WindowStyle details are exactly what I was looking for, thank you!
 

Users who are viewing this thread

Top Bottom