Rob4077
asked on
The object invoked has disconnected from its clients. AND Method 'OpenDatabase' of object '_DBEngine' failed errors
I have a pc running Office 2010 and until recently MS Access 2013 free runtime. I added some code to MS Outlook 2010 to process certain emails and automatically update an access database and it's been working fine for about a year. A few days ago I upgraded to MS Access 2016 free runtime while continuing with MS Outlook 2010 and now it's crashing. First it tells me "The object invoked has disconnected from its clients" and then it tells me "Method 'OpenDatabase' of object '_DBEngine' failed" at the line of code "Set dbs = Engine.OpenDatabase("E:\ee Link_be.ac cdb")". I have checked and the database E:\eeLink_be.accdb is linked and working.
The full code leading up to the error position is:
Function UpdateEeLink(CustJobNum As Long, fkActivityId As Long, DateRequested As Date, olItem As Object, SendReply As Boolean) As Boolean
Dim Engine As Object
Set Engine = CreateObject("DAO.DBEngine .120")
Dim dbs As Object
Dim rs As Object
Dim rs1 As Object
Dim MsgReply As Outlook.MailItem
On Error GoTo UpdateEeLink_Err:
Set dbs = Engine.OpenDatabase("E:\ee Link_be.ac cdb") '<= Crashes here
Any suggestions?
The full code leading up to the error position is:
Function UpdateEeLink(CustJobNum As Long, fkActivityId As Long, DateRequested As Date, olItem As Object, SendReply As Boolean) As Boolean
Dim Engine As Object
Set Engine = CreateObject("DAO.DBEngine
Dim dbs As Object
Dim rs As Object
Dim rs1 As Object
Dim MsgReply As Outlook.MailItem
On Error GoTo UpdateEeLink_Err:
Set dbs = Engine.OpenDatabase("E:\ee
Any suggestions?
ASKER
Unfortunately with 140 and 160 it fails at Set Engine = CreateObject("DAO.DBEngine .140")
With 120 I get past that but then get the message "The object invoked has disconnected from its clients" at " Set dbs = Engine.OpenDatabase("E:\ee Link_be.ac cdb")"
With 120 I get past that but then get the message "The object invoked has disconnected from its clients" at " Set dbs = Engine.OpenDatabase("E:\ee
You should try to use early binding: Add the reference to the current Access engine and dim all the objects explicitly as DAO-objects.
/gustav
/gustav
ASKER
That makes sense but I am not sure which one to reference. At present I reference:
Visual Basic for Applications
Microsoft Outlook 14.0 Object Library
OLE Automation
Microsoft DAO 3.6 Object Library
Microsoft 14.0 Object Library
I would have thought I drop reference to the Microsoft 14.0 Object Library and select Microsoft Office 16.0 Access Database Engine Object Library instead but it objects to that. If I drop reference to others instead, won't that cause other problems?
Visual Basic for Applications
Microsoft Outlook 14.0 Object Library
OLE Automation
Microsoft DAO 3.6 Object Library
Microsoft 14.0 Object Library
I would have thought I drop reference to the Microsoft 14.0 Object Library and select Microsoft Office 16.0 Access Database Engine Object Library instead but it objects to that. If I drop reference to others instead, won't that cause other problems?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Gustav. Sorry for the late reply. This is a crazy time at the office and I haven't actually had a chance to get it working but I have no doubt that you are correct. Thanks again.
You are welcome!
/gustav
/gustav
Set Engine = CreateObject("DAO.DBEngine
or 160 ... can't recall the exact version number.
/gustav