Issue with opening one database from another

Metric

Registered User.
Local time
Yesterday, 21:14
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!
 
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
 
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
 
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

Back
Top Bottom