News:

Choose a design and let our professionals help you build a successful website   - ITAcumens

Main Menu

Determine what version of Access is installed by using automation in VB 6

Started by nandagopal, Nov 04, 2008, 06:56 PM

Previous topic - Next topic

nandagopal

Function GetAccessVersionName creates an Access.Application object and looks at its Version property. The other routines use the result returned by this one to get Access's number and "nice" name.


' Determine the Access version by creating
' an Access.Application object and checking
' its Version property.
Public Function GetAccessVersionName() As String
Dim obj As Object

    Set obj = CreateObject("Access.Application")
    GetAccessVersionName = "Access.Application." & _
        obj.Version
    obj.Quit
End Function

' Get the Access version number from the name.
Public Function GetAccessVersionNumber() As Integer
Dim txt As String
Dim pos1 As Integer
Dim pos2 As Integer

    txt = GetAccessVersionName()
    pos2 = InStrRev(txt, ".")
    pos1 = InStrRev(txt, ".", pos2 - 1)
    txt = Mid$(txt, pos1 + 1, pos2 - pos1 - 1)
    GetAccessVersionNumber = CInt(txt)
End Function

' Get the nice style of the Access version name.
Public Function GetAccessVersionNiceName() As String
    Select Case GetAccessVersionNumber
        Case 8
            GetAccessVersionNiceName = "Access 97"
        Case 9
            GetAccessVersionNiceName = "Access 2000"
        Case 10
            GetAccessVersionNiceName = "Access 2002" ' XP
        Case 11
            GetAccessVersionNiceName = "Access 2003"
        Case 12
            GetAccessVersionNiceName = "Access 2007"
        Case Else
            GetAccessVersionNiceName = "unknown"
    End Select
End Function