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?
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?