From: shaw15222 on

From: Jeanette Cunningham on
This will work across multiple versions:

Public Function GetAccessVersion(Optional db As DAO.Database) As String
'Purpose: Return full version information for the msaccess.exe file.
'Argument: The database to examine. Current database if nothing passed in.
'Return: Full version number as string, e.g. "11.0.6566.0".
' Zero-length string on error.
'Requires: Access 95 and later. (Change the constant for Access 1/2.)
'Note: We don't use SysCmd(acSysCmdAccessVer), since we want the minor
version too.
'GetAccessVersion"

GetAccessVersion = fGetProductVersion(SysCmd(acSysCmdAccessDir) &
"msaccess.exe")
End Function



For A2007 you can use this:

MsgBox "You are currently running Microsoft Access, " _
& " version " & Application.Version & ", build " _
& Application.Build & "."



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

"shaw15222" <shaw15222(a)discussions.microsoft.com> wrote in message
news:857DDA2B-CEDE-4497-AC2F-6EBECC26903A(a)microsoft.com...
>


From: Jeanette Cunningham on
Here is the rest of the code you need if you are using
Public Function GetAccessVersion

This will work across multiple versions:

'These declarations go at the top of the module in the declaration section

'Returns size of version info in Bytes
Private Declare Function apiGetFileVersionInfoSize Lib "version.dll" Alias
"GetFileVersionInfoSizeA" _
(ByVal lptstrFilename As String, lpdwHandle As Long) As Long

'Read version info into buffer: Arguments:
' 1. Length of buffer for info. 2.Information from GetFileVersionSize. 3.
Filename of version stamped file
Private Declare Function apiGetFileVersionInfo Lib "version.dll" Alias
"GetFileVersionInfoA" _
(ByVal lptstrFilename As String, ByVal dwHandle As Long, ByVal dwLen As
Long, lpData As Any) As Long

'Returns selected version information from the specified version-information
resource.
Private Declare Function apiVerQueryValue Lib "version.dll" Alias
"VerQueryValueA" _
(pBlock As Any, ByVal lpSubBlock As String, lplpBuffer As Long, puLen As
Long) As Long



Private Function fGetProductVersion(strExeFullPath As String) As String
On Error GoTo Err_Handler
'Purpose: return the full build number for an executable.
'Return: Version number as string, e.g. "9.0.0.2719"
' Zero-length string on error.
'Argument: The executable to examine.
'Usage: fGetProductVersion(SysCmd(acSysCmdAccessDir) & "msaccess.exe")
Dim lngSize As Long
Dim lngRet As Long
Dim pBlock() As Byte
Dim lpfi As VS_FIXEDFILEINFO
Dim lppBlock As Long

'GetFileVersionInfo requires us to get the size of the file version
information first,
' this info is in the format of VS_FIXEDFILEINFO struct
lngSize = apiGetFileVersionInfoSize(strExeFullPath, lngRet)

'Proceed If the OS can obtain version info.
If lngSize Then
'The info in pBlock is always in Unicode format
ReDim pBlock(lngSize)
lngRet = apiGetFileVersionInfo(strExeFullPath, 0, lngSize,
pBlock(0))
If Not lngRet = 0 Then
'The same pointer to pBlock can be passed to VerQueryValue
lngRet = apiVerQueryValue(pBlock(0), "\", lppBlock, lngSize)

'Fill the VS_FIXEDFILEINFO struct with bytes from pBlock
'VerQueryValue fills lngSize with the length of the block.
Call sapiCopyMem(lpfi, ByVal lppBlock, lngSize)
'Build the version info strings
With lpfi
fGetProductVersion = HiWord(.dwFileVersionMS) & "." &
LoWord(.dwFileVersionMS) & "." & _
HiWord(.dwFileVersionLS) & "." &
LoWord(.dwFileVersionLS)
End With
End If
End If

Exit_Handler:
Erase pBlock
Exit Function
Err_Handler:
Resume Exit_Handler
End Function

Private Function LoWord(dw As Long) As Integer
'Retrieves the low-order word from the given 32-bit value.

If dw And &H8000& Then
LoWord = dw Or &HFFFF0000
Else
LoWord = dw And &HFFFF&
End If

End Function

Private Function HiWord(dw As Long) As Integer
'Retrieves the high-order word from the given 32-bit value.

HiWord = (dw And &HFFFF0000) \ &H10000

End Function

Public Function GetAccessVersion(Optional db As DAO.Database) As String
'Purpose: Return full version information for the msaccess.exe file.
'Argument: The database to examine. Current database if nothing passed in.
'Return: Full version number as string, e.g. "11.0.6566.0".
' Zero-length string on error.
'Requires: Access 95 and later. (Change the constant for Access 1/2.)
'Note: We don't use SysCmd(acSysCmdAccessVer), since we want the minor
version too.
'GetAccessVersion"

GetAccessVersion = fGetProductVersion(SysCmd(acSysCmdAccessDir) &
"msaccess.exe")
End Function



For A2007 you can use this:

MsgBox "You are currently running Microsoft Access, " _
& " version " & Application.Version & ", build " _
& Application.Build & "."



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

> "shaw15222" <shaw15222(a)discussions.microsoft.com> wrote in message
> news:857DDA2B-CEDE-4497-AC2F-6EBECC26903A(a)microsoft.com...