How to detect MS Access Version Installed on PC in VB

  • Thread starter Thread starter Sunny Okorie
  • Start date Start date
S

Sunny Okorie

How can detect MS Access version installed on a PC using
Visual Basic code.
I'd like to if it is version '97, 2000, or 2002.
Thanks for your help, links or other references.

A. Sunny Okorie
(e-mail address removed)
 
Sunny said:
How can detect MS Access version installed on a PC using
Visual Basic code.
I'd like to if it is version '97, 2000, or 2002.

SysCmd(acSysCmdAccessVer)

Will tell you the version:
8 - A97
9 - A2K
10 - A2002
11 - A2003
 
That will tell you what version of Access is running the Access database in
which you issue the statement.

Multiple versions of Access may be installed on the same computer, and I
don't know of any simple way to determine that, if that was the desire
rather than what version am I using.

Larry Linson
Microsoft Access MVP
 
"Larry Linson" said:
That will tell you what version of Access is running the Access database in
which you issue the statement.

Multiple versions of Access may be installed on the same computer, and I
don't know of any simple way to determine that, if that was the desire
rather than what version am I using.

Larry Linson
Microsoft Access MVP

If I had to detect which versions of Access were installed, I would use the API
calls FindFirstFile and FindNextFile to find all instances of msaccess.exe on
the computer, and then use something like the code on The Access Web to
determine the version - http://www.mvps.org/access/api/api0065.htm.

Doable, but I am sure that there are a few pitfalls along the way.....
 
Yep, I don't consider any "API solution" to be a "simple" one. Well, maybe
using the Windows Common Dialog, first one at the FAQ site, is in the
"simple" category. But the mere mention of API sends some scurrying for
cover.

If you put enough time and effort into learning APIs and using them, you can
accomplish a great deal. But, "time" and "effort" are operative words in
that statement.

Larry Linson
Microsoft Access MVP
 
"Larry Linson" said:
Yep, I don't consider any "API solution" to be a "simple" one. Well, maybe
using the Windows Common Dialog, first one at the FAQ site, is in the
"simple" category. But the mere mention of API sends some scurrying for
cover.

If you put enough time and effort into learning APIs and using them, you can
accomplish a great deal. But, "time" and "effort" are operative words in
that statement.

Larry Linson
Microsoft Access MVP

Well, using the code from The Access Web at
http://www.mvps.org/access/api/api0065.htm, together with code for
FindFirstFile/FindNextFile from my site at
http://www.applecore99.com/api/api011.asp, I put something together in a few
minutes that seems to work......
 
Information about Office programs is stored in registry keys. For example,
if you have AccessXP installed then this key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\10.0\Access\InstallRoot

will exist and will hold the location of MSAccess.exe that is associated
with XP. You could then navigate to that folder and examine the msaccess.exe
executable found there to determine exact service packs and such. Other
versions are available as well; 8.0 is A97, 9.0 is A2000 etc etc

Reading the registry is simple; there are lots of code snippets avaialbe to
read/write registry keys.
 
Marsh,
What's the useage of the SysCmd(acSysCmdAccessVer)in VB?
I'm not familiar with it - could you show me how to apply
it?
Thanks for your help.

Sunny
 
Larry,
I know you can install multiple versions. However, the
typical user would not.
This article seem to captures what I need from the Windows
Registry entry, but I don't know the language they've used
or how to port that to VB?
would you know?

;Inno Setup Extensions Knowledge Base
;Article 20 - How to detect if and which version of MS
Access is installed
;http://www13.brinkster.com/vincenzog/isxart.asp?idart=20
....
if RegQueryStringValue(HKEY_LOCAL_MACHINE,
'SOFTWARE\Microsoft\Windows\CurrentVersion\App
Paths\MSACCESS.EXE',
'', accpath) then
 
Sunny said:
What's the useage of the SysCmd(acSysCmdAccessVer)in VB?
I'm not familiar with it - could you show me how to apply


Dim strAccessVersion As String
strAccessVersion = syscmd(acSysCmdAccessVer)
Debug.Print "This program uses Access " & strAccessVersion

But as others have noted, this only tells you which version
is running that code. What other versions may be installed
on the machine is an entirely different matter.
 
Looking at the home page for that site, it says "This knowledge base is born
to help programmers to make installer packages using Inno Setup Extensions"

All you need, though, is code that will let you read the registry. There's
one approach in http://www.mvps.org/access/api/api0015.htm at "The Access
Web".
 
Sample VB Script follows:

Dim i
Dim strPath
Dim strVersion

For i = 8 to 11
strPath = GetAccessPath(i)
strVersion = GetVersion(strPath)

If Len(strPath) Then
msgbox "Microsoft Access version " & strVersion & " is installed at
" & strPath,64,"Found It"
End if
Next



Function GetAccessPath(Version)

Dim wsh
Dim strValue

On error resume next

Set wsh = CreateObject("Wscript.Shell")

strValue = wsh.RegRead("HKCR\Access.Application." & Version &
"\Shell\Open\Command\")

GetAccessPath = StripIt(strValue)

End Function

Function StripIt(Arg)
'Removes any command line parameters or quotes from the string

If InStr(Arg, "/") > 0 Then
StripIt = Trim(Left(Arg, InStr(Arg, "/") - 1))
Else
StripIt = Arg
End If

If Left(StripIt, 1) = Chr(34) Then
StripIt = Mid(StripIt, 2)
End If

If Right(StripIt, 1) = Chr(34) Then
StripIt = Left(StripIt, Len(StripIt) - 1)
End If

End Function

Function GetVersion(FilePath)
'Returns version for FilePath
Dim fso, temp

On Error Resume Next

Set fso = CreateObject("Scripting.FileSystemObject")

temp = fso.GetFileVersion(FilePath)

If Len(temp) Then
GetVersion = temp
Else
GetVersion = 0
End If

End Function
 
Back
Top