Is there a way to use VBA code to query Access for the version?
I would like to create an If statement that will do one thing for Access 2010 and a different thing for Acess 2003.
Thank for your help
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » How to find Access version in code
Richard,
Here’s a UDF that will do the trick:
Public Function AccessVersionID() As String Select Case SysCmd(acSysCmdAccessVer) Case 7: AccessVersionID = "95" Case 8: AccessVersionID = "97" Case 9: AccessVersionID = "2000" Case 10: AccessVersionID = "2002" Case 11: AccessVersionID = "2003" Case 12: AccessVersionID = "2007" Case 13: AccessVersionID = "Pirated!" Case 14: AccessVersionID = "2010" Case Else: AccessVersionID = "Unknown" End Select End Function 'AccessVersionID()
:cheers:
Andrew,
Interesting, very Interesting… Could you try out my code and see if it works for 2010 as I don’t have it and maybe it should be changed from 13 to 14 for 2010? :cheers:
Wendell & Andrew,
Thanks! :cheers:
P.S. I fixed the code above.
Coach,
This works on my Win7 SP1 64 Bit Laptop with Office 2007 SP3.
Option Compare Database Option Explicit Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long Const HKEY_LOCAL_MACHINE = &H80000002 Const KEY_QUERY_VALUE = &H1 Sub cmdRead() Dim strValue As String * 256 Dim lngRetval As Long Dim lngLength As Long Dim lngKey As Long If RegOpenKeyEx(HKEY_LOCAL_MACHINE, _ "SOFTWAREWow6432NodeMicrosoftOffice12.0Registration{91120000-0014-0000-0000-0000000FF1CE}", _ 0, KEY_QUERY_VALUE, lngKey) Then End If lngLength = 256 'Retrieve the value of the key lngRetval = RegQueryValueEx( _ lngKey, "SPLevel", 0, 0, ByVal strValue, lngLength) MsgBox "Microsoft Office SP Level: " & Left(strValue, lngLength) 'Close the key RegCloseKey (lngKey) End Sub
:cheers:
Boyd,
Please note I checked my desktop which is Win 7 SP-1 w/Office 2003 Pro SP-3 and that Registry Key does not exist! I can’t find any location in the Registry that shows the SP level of Office, however it does show up in the Help About screen of each product.
Office 2003 Registry: [noparse]HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftOffice11.0Registration{90110409-6000-11D3-8CFE-0150048383C9}[/noparse] :cheers:
Update: I found this in a different location. You could use it but then you’ll need logic to search for different versions.
Windows Registry Editor Version 5.00 [HKEY_CURRENT_USERSoftwareMicrosoftOffice11.0ExcelOptions] "SP3FirstRun"=dword:00000000
Office Version Info:
2010: http://support.microsoft.com/kb/2121559
2007: http://support.microsoft.com/kb/928116
2003: http://labnol.blogspot.com/2005/09/determine-microsoft-office-2003.html
RG, Thanks for the update.
My goal is to determine the SP level. Using Application.Build (click here) may be the easiest method since it works in Access 2003 and later.
I also found this. API: Get Version of Office Exes (detecting Office patches)
Boyd,
Nice!…
Here’s a version for any Office App.
Sub AppBuildInfo() MsgBox "You are currently running " & Application.Name _ & " version " & Application.Version & ", build " _ & Application.Build & "." End Sub
:cheers:
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.
Notifications