William Benson
vbacreations at gmail.com
Mon Dec 10 11:12:17 CST 2012
I have a function that I cannot seem to get to create an instance of
microsoft access even though it is installed on my machine I am getting
error 429 which is "ActiveX component can't create object". I do have
references set to both DAO and Microsoft Access 14.0 but I think that is
irrelevant
Public Function GetDB(strLoc As String) As Object
Dim Ac As Object
Dim GetDBEngine As Object
Dim strName As String
On Error Resume Next
Set Ac = GetObject(, "Access.Application")
If Ac Is Nothing Then
Set Ac = CreateObject("Access.Application")
End If
If Ac Is Nothing Then
Set GetDBEngine = CreateObject("DAO.DBEngine.120")
If Err.Number <> 0 Then 'try 36
Err.Clear
Set GetDBEngine = CreateObject("DAO.DBEngine.36")
If Err.Number <> 0 Then
Set GetDBEngine = CreateObject("DAO.DBEngine.35")
End If
End If
If Not GetDBEngine Is Nothing Then
Set GetDB = GetDBEngine.Workspaces(0).OpenDatabase(strLoc)
End If
End Function