MS Access VBA run time automation error 2147023170

When you run Microsoft Visual Basic code that uses Automation to control another database Microsoft Access database, you may receive this error messages. Visual Basic has established a reference to MS access due to a line of code that calls a MS Access object, method, or property without qualifying it with a MS Access object variable. Visual Basic does not release this reference until you end the program. This errant reference interferes with automation code when the code is run more than once. Automation error 2147023170 in MS Access (800706be) is occurring when Connection to type library or object library for remote process has been lost.

In this article we are reproduce the behavior for the same. For this we are write VBA code that create open the another database object. Everything is fine till, when we just open another database Form object. This error occurs when we write same code; means in another MS Access database we are write same code on Form current event that will also create the object and open the Form of that database. It's like a loop. So the two forms of different database sending request each other every time. It is infinite loop. Due to this, database can be crashed. So because of this condition, Run time automation error 2147023170(800706be), error will generated as shown in Fig 1.1.

The only way to resolve is to modify the code so that each call to a MS Access object, method, or property is qualified with the appropriate object variable or we can say just avoid this error.

MS Access VBA run time automation error 2147023170 Fig 1.1

Fig 1.1

VBA code to produce error:

Option Compare Database
Option Explicit
Private oAccess As Access.Application
Private Sub Command0_Click ()
Set oAccess = CreateObject("Access.Application")
oAccess.Visible = True
oAccess.OpenCurrentDatabase "C:\Users\admin\Documents\automationErrorDB.accdb"
oAccess.DoCmd.OpenForm "Form1"
End Sub


DISCLAIMER

It is advised that the information provided in the article should not be used for any kind formal or production programming purposes as content of the article may not be complete or well tested. Access Guru will not be responsible for any kind of damage (monetary, time, personal or any other type) which may take place because of the usage of the content in the article.