Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Access 2010 code to execute compact & repair

Posted on 2010-08-12
5
Medium Priority
?
4,447 Views
1 Endorsement
Last Modified: 2013-11-27
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.
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

Open in new window

1
Comment
Question by:OGSan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 10

Expert Comment

by:Tom
ID: 33425528
Try this:
DoCmd.RunCommand acCmdCompileAndSaveAllModules
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 2000 total points
ID: 33426250
1.Do you have the menu bar displayed in the Ribbon?
(In Access 2007, custom Menus and toolbars are now under the AddIns Tab on the Ribbon)

2. Acc 2003 and older used Menus and Toolbars, Access 2010 uses the Ribbon.
So try this instead, it does not seem to work in 2007, but perhaps it will in 2010?:
DoCmd.RunCommand acCmdCompactDatabase
Or this:
DoCmd.RunCommand acCmdRepairDatabase

;-)

JeffCoachman
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 33426266
Oh,

Or try the code here to try (Application.CompactRepair()):
http://msdn.microsoft.com/en-us/library/bb237807%28office.12%29.aspx
0
 
LVL 1

Author Comment

by:OGSan
ID: 33426453
Thanks for the replies.  I've tried the first two suggestions made above:
1.  Result of DoCmd.RunCommand acCmdCompileAndSaveAllModules
     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.  
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 33426662
;-)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question