Hi all, I have the following code which is executed when the user chooses to close the database by clicking on the exit botton...
As you can see, I've adapted it so that it should compact and repair regardless of Access version, however, it's not compacting the database in Access 2010 - why not? The code recognises that it's Access 2010, and therefore executes [SendKeys "%(YC)", False], but nothing happens...the database just goes on to close (which is correct). However, if I manually click the compact and repair button, it works!
Help please!
Code:
Private Sub Command3_Click()
Dim AccessVer As Integer
On Error GoTo Err_Command3_Click
DoCmd.RunMacro "Delete all Table Information"
AccessVer = SysCmd(acSysCmdAccessVer)
If AccessVer < 12 Then
CommandBars("Menu Bar").Controls("Tools").Controls("Database utilities").Controls("Compact and repair database...").accDoDefaultAction
DoCmd.Quit
Else
If SysCmd(acSysCmdAccessVer) = 12 Then
SendKeys "%(FMC)", False
Else
SendKeys "%(YC)", False
End If
DoCmd.Quit
End If
Exit_Command3_Click:
Exit Sub
Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click
End Sub
As you can see, I've adapted it so that it should compact and repair regardless of Access version, however, it's not compacting the database in Access 2010 - why not? The code recognises that it's Access 2010, and therefore executes [SendKeys "%(YC)", False], but nothing happens...the database just goes on to close (which is correct). However, if I manually click the compact and repair button, it works!
Help please!