Button to call ext file (1 Viewer)

Nora

Registered User.
Local time
Yesterday, 19:55
Joined
Sep 16, 2015
Messages
10
Hi Experts!

I would like to know how can I open another ms access file with a click of a button using macro (of course in the current db). :banghead:
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:55
Joined
May 7, 2009
Messages
19,230
i don't know with macro but through code, yes.
 

Nora

Registered User.
Local time
Yesterday, 19:55
Joined
Sep 16, 2015
Messages
10
Hi arnelgp

Please share with me the code. Thanks in advance...

Anyway, at the moment, I tried with hyperlink. It works fine but security message keeps popping up...
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:55
Joined
May 7, 2009
Messages
19,230
put this in a Class Module and name the class clsAccess:
Code:
Option Compare Database
Option Explicit

Private objAccessApplication As Access.Application

Private Sub Class_Initialize()
    Set objAccessApplication = New Access.Application
End Sub

Public Sub OpenDatabase(Optional ByVal sDatabase As String)

    With objAccessApplication
        If sDatabase <> "" Then .OpenCurrentDatabase sDatabase, False
        .Visible = True
    End With
    
End Sub

Private Sub Class_Terminate()

    If objAccessApplication Is Nothing Then
        objAccessApplication.Quit
        Set objAccessApplication = Nothing
    End If
    
End Sub

to use create a public function in a module

Code:
Private objAccess As clsAccess

Public Function fnOpenDataBase(Byval sDatabase as string)

    set objAccess = New clsAccess
    objAccess.OpenDatabase sDatabase

End Function

sDatabase is the complete path and name (including ext) of the database you want to open.
Now you can run the function in a macro, or directly through VBA.
to run in macro, use RunCode: fnOpenDatabase("yourDatabasefile").
 

Nora

Registered User.
Local time
Yesterday, 19:55
Joined
Sep 16, 2015
Messages
10
Hi arnelgp

Thanks! I will try and update here on the results.
 

HiTechCoach

Well-known member
Local time
Yesterday, 21:55
Joined
Mar 6, 2006
Messages
4,357
Hi arnelgp

Please share with me the code. Thanks in advance...

Anyway, at the moment, I tried with hyperlink. It works fine but security message keeps popping up...

The security warnings can easily be turned off.

The best solution depends on what you are trying to do.

Will you keep both databases opened?
 

Nora

Registered User.
Local time
Yesterday, 19:55
Joined
Sep 16, 2015
Messages
10
Hi TechCoach!

Yes both db open. I did go thru all the settings but, security notices keep on coming 😁
 

Nora

Registered User.
Local time
Yesterday, 19:55
Joined
Sep 16, 2015
Messages
10
Thank you TechCoach.

I will set up my Int Opt. But, if I'm sharing the files with others, they too have to set up their Internet Options, am I right?
 

HiTechCoach

Well-known member
Local time
Yesterday, 21:55
Joined
Mar 6, 2006
Messages
4,357
Thank you TechCoach.

I will set up my Int Opt. But, if I'm sharing the files with others, they too have to set up their Internet Options, am I right?

Yes you will have to set it for each user profile on each PC just like you would trusted locations.

If you are using Active Directory you could push the settings.
 

HiTechCoach

Well-known member
Local time
Yesterday, 21:55
Joined
Mar 6, 2006
Messages
4,357
I forgot to mention the method I prefer to use.

I find it best to use the ShelExec API to open the files.

Here is an example, with code you can use, of how it works: Document Links (Click Here)

The ShelExec API avoids the issues caused by using FollowHyperlink with files. I find it best to only use FollowHyperlink with actual web site URLs.
 

Users who are viewing this thread

Top Bottom