Link to home
Start Free TrialLog in
Avatar of dawber39
dawber39Flag for United States of America

asked on

Hide Navigation Pane

I am in the process of migrating an application from Access 2003 to 2010. The application has a function on the main menu, by double-clicking a label control that allows you to switch from the normal side back-end DB to an Archive side back-end. The two databases are separate entities and the archive side is often used to research sales data.

You can only open the program on the normal side, and if you switch to archive, you have to switch back to normal to close it. Using the Access Options I am able to make it so that Navigation Pane is hidden when opening the program on the normal side. but as soon as you switch to the Archive side - the Navigation pane opens, and seeing as it is the same application that is accessing it - the Access options still have the check in the box to hide the Navigation pane. In addition, after switching back to the normal side, the NAV Pane stays open. I need to hide the Navigation pane when it switches to archive. Below is the code/function that switches it from mode to mode



Function SetArchiveMode(SetActive)
' Called from Main Menu
Const PROCNAME = "SetArchiveMode"
Dim db As Database, rs As Recordset, Msg As String
On Error GoTo SetArchiveModeErr
   Msg = ""
   Msg = Msg & "Warning: Make sure all Tables, Queries, Forms and Reports are closed" & vbCrLf
   Msg = Msg & "before changing Archive mode." & vbCrLf & vbCrLf
   Msg = Msg & "Continue?"
   If Not Confirm(Msg) Then Exit Function

   DoCmd.Hourglass True
   If Not FormIsOpen("Settings") Then
      DoCmd.OpenForm "Settings", acNormal, , , , acHidden
     
   End If
   Set db = CurrentDb
   Set rs = db.OpenRecordset(ATTACHTABLENAME)
   rs.MoveFirst
   Do Until rs.EOF
     'Debug.Print Rs.TableName
      db.TableDefs.Delete rs!TableName
      If TableExists("Arc" & rs!TableName) Then
         db.TableDefs.Delete "Arc" & rs!TableName
      End If
      If SetActive Then  ' Set Archive mode
         DoCmd.TransferDatabase acLink, "Microsoft Access", Forms!Settings!ArcDbName, acTable, "Arc" & rs!TableName, rs!TableName
       
      Else               'Set Normal mode
         DoCmd.TransferDatabase acLink, "Microsoft Access", Forms!Settings!TblDbName, acTable, rs!TableName, rs!TableName
         DoCmd.TransferDatabase acLink, "Microsoft Access", Forms!Settings!ArcDbName, acTable, "Arc" & rs!TableName, "Arc" & rs!TableName
      End If
      rs.MoveNext
   Loop
   Forms!Settings!ArchiveActive = SetActive
   db.TableDefs.Refresh
   DoEvents
   Forms("_Menu").Recalc
SetArchiveModeExit:
   DoCmd.Hourglass False
   rs.Close
   db.Close
  'Debug.Print "Exit function."
   Exit Function
SetArchiveModeErr:
   If AppError(Err.Number, Err.Description, Err.Source, PROCNAME) Then
      Resume Next
   Else
      Resume SetArchiveModeExit
   End If

End Function
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

This is because you are using the Transfer database method to link the tables.

If you use the tabledef object, and just change the source file you will not encounter this problem.  I use something like this.  I have this in a larger subroutine, that lets the user select the backend using the FileOpenSave API call, and which then loops through each of the linked tables.  But the pertinent code is:

     If TableExists(TableName) Then
           Set tdfDest = dbDest.TableDefs(Tablename)
           tdfDest.Connect = ";DATABASE=" & Backend
           tdfDest.RefreshLink
      Else
           Set tdfDest = dbDest.CreateTableDef(TableName)
           tdfDest.Connect = ";DATABASE=" & Backend
           tdfDest.SourceTableName = TableName
           dbDest.TableDefs.Append tdfDest
      End If
add this command after relinking the tables

RunCommand acCmdWindowHide
add this after relinking the tables
DoCmd.RunCommand acCmdWindowHide
ASKER CERTIFIED SOLUTION
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dawber39

ASKER

Fyed - that is perfect - thank you
This is perfect. Adding the sub routine easy
If you just use the subroutine, which really doesn't do any more than what C1 suggested, then you will still see the navigation pane displayed while your code is running.

If you replace your Transferdatabase method calls with the code that simply changes the connection via the tabledef object, you will never see the navigation pane open at all.
I used the subroutine - and it works fine with no sight of the navigation pane. But thank you for the suggestion.This is going to be a big project, so I am sure I will be back. Thanks again to all of you