Alex & Access

News, links, downloads, tips and tricks on Microsoft Access and related

About Me Search
My Photo
Name:Alex Dybenko

Location:Moscow, Russia
Google
 
Web AccessBlog.net

Wednesday, June 06, 2007

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


 


Technorati tags: , ,

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home