How to get reference to DBEngine.
Once you need to write a program or addin, which works with installed version of DAO, it can be DAO 3.5, 3.6 or 12 (Access 2007). So you need to use late binding and get reference to latest version of DAO. Simple CreateObject("DAO.DBEngine") will not work. Here a function, which do this task:
Public Function GetDBEngine() As Object
On Error Resume Next
'try 120
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
End Function
1 Comments:
Thanks Alex! Not many web pages are mentioning the '120' version - you helped me a lot with that one!
Post a Comment
<< Home