Hi everybody. I'm hoping somebody could help me out with this issue, cause i've searched all over the internet but cannot seem te find any solution.
Idea:
1. I have an excelsheet, containing some information that needs to be transfered into an access database.
2. In order to do that, i've created a macro in an access database
3. The macro in the access-database, is launched by a press on a button in the excelsheet that contains a certain vba-code.
Problem:
The path of the database in the vba-code may not be an absolute path. If i use an absolute path, the code works. When i try to make it relative, it fails with a "Run-time Error 242: Object Required".
Does anyone have an idea how to solve this? Or what i'm doing wrong?
This is the working code with absolute path:
Sub GetAccess()
Application.StatusBar = "Working in MS Access"
Dim MyAccess As Object
Set MyAccess = CreateObject("Access.Application")
MyAccess.OpenCurrentDatabase "C:\Blue Books\start project\database.mdb"
MyAccess.DoCmd.RunMacro "Run"
MyAccess.Quit
End Sub
Now this is what i've changed (with the error as result):
MyAccess.OpenCurrentDatabase "C:\Blue Books\start project\database.mdb"
i changed into:
MyAccess.OpenCurrentDatabase (App.Path & "\database.mdb")
Is there anyone that has an idea of what went wrong? Or how i can make this work?
Thanks in advance for your helps
Idea:
1. I have an excelsheet, containing some information that needs to be transfered into an access database.
2. In order to do that, i've created a macro in an access database
3. The macro in the access-database, is launched by a press on a button in the excelsheet that contains a certain vba-code.
Problem:
The path of the database in the vba-code may not be an absolute path. If i use an absolute path, the code works. When i try to make it relative, it fails with a "Run-time Error 242: Object Required".
Does anyone have an idea how to solve this? Or what i'm doing wrong?
This is the working code with absolute path:
Sub GetAccess()
Application.StatusBar = "Working in MS Access"
Dim MyAccess As Object
Set MyAccess = CreateObject("Access.Application")
MyAccess.OpenCurrentDatabase "C:\Blue Books\start project\database.mdb"
MyAccess.DoCmd.RunMacro "Run"
MyAccess.Quit
End Sub
Now this is what i've changed (with the error as result):
MyAccess.OpenCurrentDatabase "C:\Blue Books\start project\database.mdb"
i changed into:
MyAccess.OpenCurrentDatabase (App.Path & "\database.mdb")
Is there anyone that has an idea of what went wrong? Or how i can make this work?
Thanks in advance for your helps