Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wouldn't CreateObject create a duplicate instance of an open object?

Status
Not open for further replies.

Perissos

Technical User
Sep 21, 2010
1
US
Hi everyone,
I have a database which when a button is pressed, it opens an excel file to allow a user to key in information. I didn't know how to set up connections to transfer data from one source to another so I linked the excel file as a table in the access database. When the user is finished entering data, they click on a button and its supposed to run a function in access to do some calculations, store the data in a table, and close the excel workbook without saving the data.

The problem I am running into is that it is opening a second instance of the database.
This is the code in the excel workbook to run the function in access

Dim BPMObj As Object
Set BPMObj = GetObject("Accessdatabase.accdb")

BPMObj.Run "LoadBPMData"

In all my searching I keep finding that you need to create an object in order to transfer data from excel to access.. such as this that I found on your forum

Private Sub Workbook_Open()
Dim strMyDatabase As String
strMyDatabase = "C:\DatabaseName.mdb"
Set appAccess = CreateObject("Access.Application") appAccess.OpenCurrentDatabase strMyDatabase appAccess.Visible = True

But, my question is this. If Access is open and you run this, wouldn't it do the same thing and create another database?

Is there a way to reference an already open object without creating another instance of it?
 
Take a look at the create Workspace method. I believe that might be what your looking for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top