Opening Another Access Database onClick

V

VWP1

I would like to open another Access database without closing the current
database. I wish to do this with a button on a form.

Please help.
 
S

Stefan Hoffmann

hi,

I would like to open another Access database without closing the current
database. I wish to do this with a button on a form.

Dim AccessExecutable As String
Dim DatabaseFile As String

AccessExecutable = _
"C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE"

DatabaseFile = """C:\PathTo\Database.mdb"""

Shell AccessExecutable & " " & DatabaseFile

Depending on your installation you don't need the path to the executable,

AccessExecutable = "MSACCESS.EXE"

can be sufficent. The quotation marks around the database filename are
necessary.


mfG
--> stefan <--
 
F

fredg

I would like to open another Access database without closing the current
database. I wish to do this with a button on a form.

Please help.

Code a command button's Click event:

Application.FollowHyperlink "C:\FolderName\MyDatabaseName.mdb"
 
V

VWP1

Is this correct?

Private Sub geo_Click()
On Error GoTo Err_geo_Click

Dim AccessExecutable As String
Dim DatabaseFile As String

AccessExecutable = _
"C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE"

DatabaseFile = """E:\databases\geo.mdb"""

Shell AccessExecutable & " " & DatabaseFile

Exit_geo_Click:
Exit Sub

Err_geo_Click:
MsgBox Err.Description
Resume Exit_geo_Click

End Sub
 
V

VWP1

Thank you; it works well. Is there a way I could automatically bypass the
warning of "hyperlinks can be harful to your computer..." prompt? I ask
this, because I know the target mdb is in a trusted location.
 
V

VWP1

Well it's working, and I encountered a prompt which warned me that hpyerlinks
can be harmful..., ...but the prompt hasn't come up several times now; I've
opened and closed the target mdb a few times, and I do anticipate the prompt
coming back at some point in time, perhaps, when I reboot my computer, or
reopen the current database (where the hyperlink resides). So my question
regarding the automatic bypass still stands.
 
V

VWP1

Well, I got the target (fn.mdb) to open, but it doesn't become the focus, it
sits at the bottom in my taskbar. Not a real problem, but I'll be opening it
up dozens of times per afternoon (and late evening). I'd like it to become
the focus instead of waiting for me to click the taskbar.
 
D

Dirk Goldgar

VWP1 said:
Thank you; it works well. Is there a way I could automatically bypass the
warning of "hyperlinks can be harful to your computer..." prompt? I ask
this, because I know the target mdb is in a trusted location.

You could use the function posted here:

http://www.mvps.org/access/api/api0018.htm
API: Start an app with ShellExecute

which calls the Windows ShellExecute API.
 
J

Jack Leach

No, there is not a way to get around it, aside from maybe hacking some
security settings to your computer.

Application.Followhyperlink opens a file as if it were something downloaded
from the internet... it will call whatever builtin system security prompts go
with that.

Using the ShellExecute API that Dirk pointed you to is my preffered
method... you can dictate what the focus is, window size, etc etc, and do not
need the path to the executable, as it pulls the information from the
registered application for the file passed.

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top