Traditionally you may have used something like: –
Dim
DBEngine As Object
Set DBEngine = CreateObject("DAO.DBEngine")
Which you would expect to get the latest installed/registered version of the engine. This however nolonger works, so we must be a little more indepth and use a function to get our object. Such as: –
Public
Function DAO_DBEngine() As Object
On Error Resume Next
‘try Access 2007 (DAO Engine version 120)
Set GetDBEngine = CreateObject("DAO.DBEngine.120")If Err.Number <> 0 Then
‘try DAO version 3.6
Err.Clear
Set GetDBEngine = CreateObject("DAO.DBEngine.36")If Err.Number <> 0 Then
Set GetDBEngine = CreateObject("DAO.DBEngine.35")
End If
End If
End Function
If the function returns nothing the object has not been created, otherwise it will return the latest available version of DAO, and allow the querying of the database engine.