Open external form in another database

Alvein17

New member
Local time
Today, 19:18
Joined
Sep 2, 2021
Messages
29
Dear All,

heloo,

how to open external database? i was created button (Input DB) in my access application to open file Kategori.mdb but it's not works.
here i capture picture, please see the picture below:

From this:
1634793967642.png


to this:
1634794321418.png


so, when i click input DB it will open kateogri.mdb

here i share my query:
Dim accapp As Access.Application

Set accapp = New Access.Application

accapp.OpenCurrentDatabase ("D:\Access Application\Kanrigenka Application\AOCR App\Kategori.mdb")
accapp.Visible = True
End Sub



can you suggest to me how to fix my query?

thank you All.
 
Last edited:
Code:
Option Explicit
Dim accapp As Access.Application

Private Sub button_Click()
    If Not (accapp Is Nothing) Then
        'accapp.Quit
        Set accapp = Nothing
    End If
    Set accapp = New Application
    accapp.Visible = True
    accapp.OpenCurrentDatabase ("D:\Access Application\Kanrigenka Application\AOCR App\Kategori.mdb")
    accapp.DoCmd.OpenForm "theFormYouNeedToOpen"
End Sub
 
ArnelGP's solution is probably the best. Another thing you could do is the following:

Create a macro in your second database. Then call the following procedure in your first database:

Code:
Sub OpenMacroInOtherDatabase(macroName As String, Optional parameters As String)
    Call Shell("msaccess.exe YourFilePath/YourFileName.accdb /x " & macroName & IIf(IsStringEmpty(parameters), "", "/cmd " & parameters))
End Sub

This will open a new access instance and execute the macro. With this you can open forms, call vba and much more.
 

Users who are viewing this thread

Back
Top Bottom