First, what I want to do is open a specific access database from Excel, enter some records, close the Access application completely, and continue with Excel.
All is working fine but when I exit the database, the Access application does not quit until I close the Excel application that created it.
In my module, I have the following code:
Option Explicit
Public obj_Access As Object
Sub Add_Web_Reports()
Set obj_Access = CreateObject("Access.Application"
obj_Access.OpenCurrentDatabase ("C:\Some_database.mdb"
End Sub
Now, the reason I declared the object as Public is because I have three different procedures that call the same database, including the above procedure. The difference between them is that the other two open the database, run a macro, then close the database. These work fine and the access object is set to nothing and goes away.
In the above procedure, I need the user to be able to open the database, do some work, then exit. If I set obj_Access to Nothing, when the user clicks the menu option in Excel to open the database, it opens then closes immediately.
I understand why it is doing what it's doing, I just don't know how else to go about what I want to do. It is not a big deal, it just seems messy to have the Access object still live when the user is actually finished with Access.
Thanks in advance for any suggestions.
All is working fine but when I exit the database, the Access application does not quit until I close the Excel application that created it.
In my module, I have the following code:
Option Explicit
Public obj_Access As Object
Sub Add_Web_Reports()
Set obj_Access = CreateObject("Access.Application"
obj_Access.OpenCurrentDatabase ("C:\Some_database.mdb"
End Sub
Now, the reason I declared the object as Public is because I have three different procedures that call the same database, including the above procedure. The difference between them is that the other two open the database, run a macro, then close the database. These work fine and the access object is set to nothing and goes away.
In the above procedure, I need the user to be able to open the database, do some work, then exit. If I set obj_Access to Nothing, when the user clicks the menu option in Excel to open the database, it opens then closes immediately.
I understand why it is doing what it's doing, I just don't know how else to go about what I want to do. It is not a big deal, it just seems messy to have the Access object still live when the user is actually finished with Access.
Thanks in advance for any suggestions.