Nav Pane Opening Automatically when Importing Linked Table: Solve with Ribbon Callback?

Hi everyone,

Environment: Access 2010 BE, FE on each user's machine.

I have set up a very basic default ribbon, and I am hoping that someone will know how to help me trap when the import buttons are clicked. I have used an OnAction attribute with the Access built in button--but this doesn't work -- the callback procedure doesn't run. Is it because Access opens a Wizard (or because it's built in? )

This tab is only visible when a database admin menu is open. I have a procedure that opens the Nav pane, with everything hidden except some specific queries (and the only objects available are tables and queries). The idea is to allow the user to link locally to Excel spread sheets if they want, plus there is some custom importing (not a wizard) that is initiated on this form --so the Nav Pane is needed--in specific cases. So what I'm trying to do is trap when the import wizard buttons are clicked, so that the form's flag can be set properly (and the Nav pane can be closed again).

Here is the section of XML.
  <tab id="tabManageData" label="Manage Data" 
     <group id="MyGroupImport" label="Import &amp;&amp; Link" autoScale="true">
          <button idMso="ImportSavedImports" size = "large" visible="true"/>
          <button idMso="DatabaseLinedTableManager" size = "large" visible="true"/>                                
          <button idMso="ImportExcel" size = "large" visible="true"
                                            onAction = "OpenNavPane"/>                
          <button idMso="ImportAccess" size = "large" visible="true"
                                            onAction = "OpenNavPane"/>                 
          <button idMso="ImportOutlook" size = "large" visible="true"
                                            onAction = "OpenNavPane"/>            
     <group idMso="GroupExport"/>
     <group idMso="GroupAccessTools"/>

Open in new window

And here is the callback procedure (minus the error handler):
Public Sub OpenNavPane(Ctl As Object)   'Late Binding
On Error GoTo HandleErr

Debug.Print "In OpenNavPane Callback"   'doesn't print

Call Forms("f5DBAMenu").ShowLockedNavPane

Open in new window

I'd really appreciate it if someone could point me in the right direction.

Thanks :)
Who is Participating?
shelldeeAuthor Commented:
Hi again,

I figured it out. (Sorry I should have gotten some sleep before posting...)

I made custom buttons for the import buttons, and then used Docmd.RunCommand to run the wizards.

Here's the XML for the buttons for anyone else new to ribbons (like me) who might be looking for this:
<button id="MyImportExcel" size="large" imageMso="ImportExcel" 
                     label = "Excel" visible="true" screentip="Import Excel Spreadsheet"
                    supertip="Import data from or link to data in a Microsoft Excel File" 
 <button id="MyImportAccess" size = "large" imageMso="ImportAccess"
                    label="Access" visible="true" screentip="Import Access Data"  
                   supertip="Import data from or link to data in another Access Database"
 <button id="MyImportOutlook" size = "large" imageMso="ImportOutlook"
                    label="Outlook Folder" visible="true" screentip="Import Outlook Folder"
                    supertip="Import  or link to an Outlook folder" 

Open in new window

And here's the Callback:
Public Sub OpenNavPane(Ctl As Object)   'Late Binding
On Error GoTo HandleErr

If fFormIsLoaded("f5DBAMenu") Then
    Call Forms("f5DBAMenu").ShowLockedNavPane
    Select Case Ctl.ID
        Case "MyImportExcel"
            DoCmd.RunCommand acCmdImportAttachExcel
        Case "MyImportAccess"
            DoCmd.RunCommand acCmdImportAttachAccess
        Case "MyImportOutlook"
            DoCmd.RunCommand acCmdImportAttachOutlook
    End Select

End If  

Open in new window

Thanks anyways to anyone who took a look for me :)

(I'll check back and close this later---just in case one of you sees an error with what I've done.)
shelldeeAuthor Commented:

Thank you for your kind words.  :)

I know just enough to be dangerous :) --so I didn't want to let stand my soln, as the soln, unless one of you had checked what I did.

So thank you for taking the time to review the answer!

Next time, I will explicitly ask for comments, rather than deleting the question.

Thanks again,
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.