Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2002

    Unanswered: calling menu bar controls

    I want a cmd button on a form that lets the user "compact and Repair" the database.
    The menu's have been removed.
    There is a hidden menu, called "Developer" which is only accessible thru a password protected form, that has the menu option "Compact and Repair Database..."

    Here's what I have: (in a module)

    Public Sub CompactDB()
    Commandbars("Developer").Controls("Compact and Repair Database...").accDoDefaultAction
    End Sub

    The menubar is labeled Developer and Compactandrepairdatabase is listed in the first pull down

    Any suggestions?

  2. #2
    Join Date
    Apr 2002
    I've been trying the same for ages, and never got it to work.
    Sorry to say...

    It is possible to compact and repair from code, but than from within a second database: DBEngine.CompactDatabase Name1, Name2

    You cannot compact a database that you are working in from within itself, as far as I know.

    It is possible to use the menu-button Access provides in itself, that works like a charm.
    However there I believe you have to distinguish between your Database and the running Access-application.
    Using the Access-menu bar for compact and repair, your Access-application first closes your database, than compacts (including possible file renaming) your database and than re-opens your database.

    So you may understand that your database cannot close itself, than compact itself, renames and re-opens again.


  3. #3
    Join Date
    Jan 2003
    Aberdeen, Scotland, UK

    what you can do..

    is get the database to open another application (i.e. another database) and then close.

    The other application should:

    this database should have a form that open automatically. This form should have a timer event set to (say) 10 secs. This timer event should opent the database you want to compact with the /compact /repair startup options. Then close.

    Make sense?

  4. #4
    Join Date
    Apr 2002
    could you be a little more specific please. what i gather is:
    DB1 is open with a form that has a cmd button that "compacts"
    then on the on click event:
    DB2 opens with hidden form that
    closes DB1
    compacts DB1
    opens DB1

    DB2 then closes

    is it something like that or am I completely lost?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts