Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8388827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:33:21+00:00 2026-06-09T18:33:21+00:00

I have inherited an Access DB, and it is erroring out when trying to

  • 0

I have inherited an Access DB, and it is erroring out when trying to open with this error message:

Run-time error ‘5’:
Invalid procedure or argument

I have traced it to the following code in the VBE:

Set cbMainMenu = CommandBars.Add(Name:="OIG Main Menubar", _
Position:=msoBarTop, MenuBar:=True, Temporary:=True)

I have added a check before this from some Googling research, but it does not seem to work, as it is still erroring (with and without the error handling change):

    On Error Resume Next
    Application.CommandBars(cbMainMenu).Delete
    On Error GoTo 0

Anyone have any ideas, or can point me in the right direction to fix this error? I am going to keep plodding at it for a bit.

EDIT:

This does not appear to be the main, initial error. I am working to find it now, and will re-post if/when I find it.

EDIT2:

This is what is actually causing the error, going to look around and see if I can take care of it:

Set cbcToolsDBCompact = cbpToolsMenu.Controls.Add(Id:=CommandBars("Menu Bar").Controls("Tools").CommandBar.Controls("Database Utilities").CommandBar.Controls("Compact And Repair Database...").Id)

EDIT3: Changing the above code to:

Set cbcToolsDBCompact = cbpToolsMenu.Controls.Add(Id:=2071)

Fixed this issue, and the option for comact/repair is there now. (and it even works). Since no one really posted a specific answer, other than in comments, I am going to use the ‘Answer your own Question’ option at the bottom so this has an answer for the future. Also, I found the code for this here:

MS Access: how to compact current database in VBA

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T18:33:23+00:00Added an answer on June 9, 2026 at 6:33 pm

    Answering my own question here.

    This was an issue with the “Compact and Repair Database” option being moved from where it was in Access 2003.

    The VBA code is adding it as a menu option, and in 2003, this is what the code looked like:

    Set cbcToolsDBCompact = cbpToolsMenu.Controls.Add(Id:=CommandBars("Menu Bar").Controls("Tools").CommandBar.Controls("Database Utilities").CommandBar.Controls("Compact And Repair Database...").Id)
    

    In 2007, as per this issue, found here, MS Access: how to compact current database in VBA is how this needs to be handled:

    Set cbcToolsDBCompact = cbpToolsMenu.Controls.Add(Id:=2071)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have inherited a poorly designed Access 2002 database. I am trying to troubleshoot
Possible Duplicate: C++ Inherited template classes don't have access to the base class I'm
I have inherited a SQL Server 2008 database to which calling applications have access
Ok this is going to sound strange, but I have inherited an app that
Please help me on this puzzle i have class D inherited fronm class B
I have a fairly simple database that I inherited. For the purposes of this
I have inherited an Access 2007 database that has been split so the tables
Due to a merger, we have inherited a couple of legacy apps which run
so I have inherited an Access DB with different naming conventions applied to tables.
I have inherited a terribly written MS Access database that I need to import

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.