How to stop Access from closing when opened with VBA

Panik

New Member
Joined
Nov 12, 2009
Messages
20
Hi,

I would like to open an existing access db and the code seems to work with no errors, but access opens and immediately closes. How do I keep it open. Running Office 2013

I have seen people with the same issue, but have yet to find a remedy.

Code:
Private Sub OpenDB_Click()

     Dim db As New Access.Application
     Set db = CreateObject("Access.Application")
     db.Application.Visible = True
     db.OpenCurrentDatabase "C:\Users\jsmith\Desktop\Purchase Order DB.accdb"

End Sub

Thanks,
Jim
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
No, I just tried and it behaves exactly the same. Access opens and closes very quickly.
 
Upvote 0
Does:

Code:
Private Sub OpenDB_Click()

     Dim db As New Access.Application
     Set db = CreateObject("Access.Application")
     db.Application.Visible = True
     db.usercontrol = true
     db.OpenCurrentDatabase "C:\Users\jsmith\Desktop\Purchase Order DB.accdb"

End Sub

do anything?
 
Upvote 0

Forum statistics

Threads
1,221,838
Messages
6,162,286
Members
451,759
Latest member
damav78

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top