OGSan
asked on
Access 2010 code to execute compact & repair
Hi, Experts -
I'm using MS Access 2010 and have a routine that runs fine under Access 2003 but which issues an error message, "Invalid procedure call or argument" under 2010. I've attached the snippet of code below.
Question - Is there a way to modify this code so it will run under 2010, as well as be backward compatible with 2003? The databases were created under 2003, but the company will be migrating over to Office 2010 product line later this summer.
I'm using MS Access 2010 and have a routine that runs fine under Access 2003 but which issues an error message, "Invalid procedure call or argument" under 2010. I've attached the snippet of code below.
Question - Is there a way to modify this code so it will run under 2010, as well as be backward compatible with 2003? The databases were created under 2003, but the company will be migrating over to Office 2010 product line later this summer.
MsgBox ("Compact & repair will commence once this msgbox is closed. This will take several seconds. Please do not close ACCESS window.")
CommandBars("Menu Bar"). _
Controls("Tools"). _
Controls("Database utilities"). _
Controls("Compact and repair database..."). _
accDoDefaultAction
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Oh,
Or try the code here to try (Application.CompactRepair ()):
http://msdn.microsoft.com/en-us/library/bb237807%28office.12%29.aspx
Or try the code here to try (Application.CompactRepair
http://msdn.microsoft.com/en-us/library/bb237807%28office.12%29.aspx
ASKER
Thanks for the replies. I've tried the first two suggestions made above:
1. Result of DoCmd.RunCommand acCmdCompileAndSaveAllModu les
Nothing happened, nada, zip.
2. Result of DoCmd.RunCommand acCmdCompactDatabase
Error message, "You cannot compact the open database by running a macro or Visual Basic code.
Instead of using a macro or code, click the File tab and then click Compact and Repair Database."
I'm going to go with this since - even though it doesn't do anything - it at least informs the MS Access 2010 user of what to do and where to do it.
1. Result of DoCmd.RunCommand acCmdCompileAndSaveAllModu
Nothing happened, nada, zip.
2. Result of DoCmd.RunCommand acCmdCompactDatabase
Error message, "You cannot compact the open database by running a macro or Visual Basic code.
Instead of using a macro or code, click the File tab and then click Compact and Repair Database."
I'm going to go with this since - even though it doesn't do anything - it at least informs the MS Access 2010 user of what to do and where to do it.
;-)
DoCmd.RunCommand acCmdCompileAndSaveAllModu