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

Posted on 2012-09-03
Last Modified: 2012-09-05
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 :)
Question by:shelldee

    Accepted Solution

    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.)

    Author Comment


    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,

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
    Article by: Martin
    Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
    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…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    759 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

    10 Experts available now in Live!

    Get 1:1 Help Now