How to: Vary the navigation pane per environment
Show a group or an entry in the navigation pane only during development, only in the ACCDB file, or only to users the application allows.
Requires WKL Forms Object Library 1.50 or later.
Solution overview
Every group and entry in the model has a condition with three parts, all of which must hold, just like the ribbon commands: Profiles (the Linked Tables Manager's connection profile), the kind of file (ACCDB, ACCDE, or runtime), and Function (a public VBA function without arguments that returns True). Anything whose condition doesn't hold isn't written to the pane at all. Because conditions are evaluated when the model is applied, the application applies it at startup.
Implementation
In the navigation pane designer, on the Groups and entries page, select the group or entry and fill in Visible when, for example ACCDB for a group of development tables. Then apply the model every time the application starts, for example in the Load event of the startup form:
Private Sub Form_Load()
Dim pane As Object
Set pane = CreateObject("WklForms.NavPane")
pane.Apply
End Sub
If the role comes from the sign-in, set it before you apply the model:
Public Function IsAdmin() As Boolean
On Error Resume Next
IsAdmin = Nz(TempVars("role"), "") = "Admin"
End Function
TempVars("role") = "Admin"
CreateObject("WklForms.NavPane").Apply
Remarks
- The profile is the one set with
WklNavPane.ProfileorWklRibbon.Profile(the two share it); otherwise, it's the profile that most linked tables use (as withWklLinkManager.DetectEnvironment). - The build tool applies the model on the build computer, in an ACCDB file; an ACCDE file made from it carries that pane until the application applies the model itself.
Applyreturns the entries whose objects don't exist in the database, one per line; it never shows a dialog box.- Hiding is a convenience, not security: an object left out of the pane can still be opened by code or by name.
Related topics
- How to: Show commands only in development: the same conditions on the ribbon