What to do with this error when I run the macro Company and repair command button.

Posted on 2014-08-10
Last Modified: 2014-08-15
I get an error from this code:

Private Sub Command5_Click()
On Error GoTo Err_Command5_Click

CommandBars("Menu Bar"). _
Controls("Tools "). _
Controls("Database utilities"). _
Controls("Compact and repair database..."). _

Exit Sub

MsgBox Err.Description
Resume Exit_Command5_Click

End Sub

I found this code on line and thought it would work.


See attached image
Question by:cssc1
    LVL 74

    Accepted Solution

    The last time I checked, You cannot really use automation to C&R the current database.
    ...the only way to do this was with sendkeys:
    See the solution here:


    Author Closing Comment

    LVL 74

    Expert Comment

    by:Jeffrey Coachman

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Access Join Query 12 31
    VBA exception error 5 25
    Access left join query 5 20
    How prevent more than one record as the default 8 14
    The System Center Operations Manager 2012, known as SCOM, is a part of the Microsoft system center product that provides the user with infrastructure monitoring and application performance monitoring. SCOM monitors:   Windows or UNIX/LinuxNetwo…
    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
    The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now