Excel / Access Runtime Error

audioboxer

New Member
Joined
Aug 13, 2012
Messages
23
Hi Everyone,

I needed a solution for retrieving data from Access and using my trusty MrExcel “VBA and Macros” book I came up with the below code. This code works beautifully until I close Excel, reopen the File and try to run it again, at which point I get this error.

“Run-time Error ‘-2147417848 (80010108)’:

Automation Error
The Object invoked has disconnected from its clients.”

If I try to debug or end, excel just crashes. This code will not work again successfully until I repair Microsoft Office via Add/Remove programs. Any ideas? It has something to do with the connection to Access because when I try to Import Data via the built in Ribbon icon, this also crashes excel until I repair Microsoft Office.

Code:
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim sSQL As String
Dim FinalRow As Long
 
Set WSOrig = ActiveSheet
sSQL = "SELECT Vendor FROM Vendors"
 
MyConn = "C:\Users\sbg\Desktop\TestData.accdb"
 
With cnn
    .Provider = "Microsoft.ACE.OLEDB.12.0"
    .Open MyConn
End With
 
Set rst = New ADODB.Recordset
rst.CursorLocation = adUseServer
rst.Open Source:=sSQL, ActiveConnection:=cnn, CursorType:=adOpenDynamics, LockType:=adLockOptimistic, _
    Options:=adCmdText
 
rst.MoveFirst
With Me.VendorList
    Do
        .AddItem rst![Vendor]
        rst.MoveNext
        Loop Until rst.EOF
End With
 
rst.Close
cnn.Close


Using Microsoft Office Standard 2010 x86
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Just an update.... I actually never determined the cause, the issues caused were related to using Office 2010. Since upgrading to 2016 office suite I have not had this issue.
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,164
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top