Note that there are some explanatory texts on larger screens.

plurals
  1. PO"Invalid procedure or argument" error
    text
    copied!<p>I have inherited an Access DB, and it is erroring out when trying to open with this error message:</p> <blockquote> <p>Run-time error '5':<br> Invalid procedure or argument</p> </blockquote> <p>I have traced it to the following code in the VBE:</p> <pre><code>Set cbMainMenu = CommandBars.Add(Name:="OIG Main Menubar", _ Position:=msoBarTop, MenuBar:=True, Temporary:=True) </code></pre> <p>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):</p> <pre><code> On Error Resume Next Application.CommandBars(cbMainMenu).Delete On Error GoTo 0 </code></pre> <p>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.</p> <p><strong>EDIT:</strong> </p> <p>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.</p> <p><strong>EDIT2:</strong> </p> <p>This is what is actually causing the error, going to look around and see if I can take care of it:</p> <pre><code>Set cbcToolsDBCompact = cbpToolsMenu.Controls.Add(Id:=CommandBars("Menu Bar").Controls("Tools").CommandBar.Controls("Database Utilities").CommandBar.Controls("Compact And Repair Database...").Id) </code></pre> <p><strong>EDIT3:</strong> Changing the above code to:</p> <pre><code>Set cbcToolsDBCompact = cbpToolsMenu.Controls.Add(Id:=2071) </code></pre> <p>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:</p> <p><a href="https://stackoverflow.com/questions/1460129/ms-access-how-to-compact-current-database-in-vba">MS Access: how to compact current database in VBA</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload