Software

Add a button to an Access form that tells you which version is running

Users don't always know what version of Access they're using -- which can slow things down when you're helping troubleshoot a problem. Make it easy for them (and for you) by creating a convenient button that lets them know.

If you support more than one version of Access, you may often need to ask users which version is running before you can help them with a problem. Don't have them guess! Create a button somewhere on their application form that, when clicked, will tell them exactly what version is running on their PC. Follow these steps:

  1. Open the form in Design view.
  2. Click the command button tool in the Form Controls toolbox. In Access 2007, click the Button form control in the Controls Group on the Forms Design tab.
  3. Click Cancel to close the Forms Control Wizard.
  4. Change the button caption to Which Version? (Figure A).

Figure A

  1. Right-click the button.
  2. Choose Build Event.
  3. Type the following code at the prompt (Figure B):

Private Sub Command6_Click()
Select Case SysCmd(acSysCmdAccessVer)
Case 7
MsgBox "This is Access 95", vbOKOnly
Case 8
MsgBox "This is Access 97", vbOKOnly
Case 9
MsgBox "This is Access 2000", vbOKOnly
Case 10
MsgBox "This is Access 2002", vbOKOnly
Case 11
MsgBox "This is Access 2003", vbOKOnly
Case 12
MsgBox "This is Access 2007", vbOKOnly
End Select
End Sub

Press [Alt] +[ Q].

Figure B

Now, users simply have to click the Which Version? button to let you know what version they are using (Figure C).

Figure C


Miss an Access tip?

Check out the Microsoft Access archive and catch up on other Access tips.

Help users increase productivity by automatically signing up for TechRepublic's free Microsoft Office Suite newsletter, featuring Word, Excel, and Access tips, delivered each Wednesday.

2 comments
john.a.wills
john.a.wills

At the end of the case statement should be an ELSE with the message "Unknown version of Access".

Marshwiggle
Marshwiggle

... it would be best practice, even though you would not be writing VBA code for any version earlier than 95 (I think?) and, hopefully it will be a while before we have to account for anything later than 2007. Also, though in this example it would not be necessary, I would give the command button a meaningful name, such as "cmdWhichVersion", and streamline the code something like this: Private Sub cmdWhichVersion_Click() Dim strMsg As String Select Case SysCmd(acSysCmdAccessVer) Case 7 strMsg = "This is Access 95" Case 8 strMsg = "This is Access 97" Case 9 strMsg = "This is Access 2000" Case 10 strMsg = "This is Access 2002" Case 11 strMsg = "This is Access 2003" Case 12 strMsg = "This is Access 2007" Case Else strMsg = "Unknown Version" End Select MsgBox strMsg, vbOKOnly End Sub Functionally, it wouldn't make any difference, but it's prettier, I think.

Editor's Picks