• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 627
  • Last Modified:

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" 
                getVisible="ShowHideMngDataTab">
     <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>
     <group idMso="GroupExport"/>
     <group idMso="GroupAccessTools"/>
  </tab>

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 :)
Shelley
0
shelldee
Asked:
shelldee
  • 2
1 Solution
 
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" 
                    onAction="OpenNavPane"/>                            
 <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"
                   onAction="OpenNavPane"/>                  
 <button id="MyImportOutlook" size = "large" imageMso="ImportOutlook"
                    label="Outlook Folder" visible="true" screentip="Import Outlook Folder"
                    supertip="Import  or link to an Outlook folder" 
                    onAction="OpenNavPane"/>

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 :)
SD

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

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,
Shelley
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now