Color scheme: Riviera
You are here: start » en » Documentation » Microsoft Access development tools » WKL Forms Object Library » WKL Forms Object Library how-to guides » How to: Design the navigation entries

How to: Design the navigation entries

Give a WklNavBar its groups and entries, either fixed ones saved with the form or ones that depend on the user or the data at run time.

Requires WKL Forms Object Library 1.24 or later.

Solution overview

Entries you create in Design view are saved with the form, whether you use the designer (property sheet, Other tab, [...] in the Custom row, Entries page) or code in Design view. At run time, AddGroup, AddItem, RemoveItem, ItemVisible, and ItemEnabled change the bar only until the form closes; Items gets or sets all groups and entries as a single text.

Implementation

In the designer, Group and Entry add a group or an entry where the selection is (in the selected group, next to the selected entry, or at the bottom edge); Move up and Move down move it among the entries in its place; and Place moves it to another group, to the top without a group, or to the bottom edge. Choose … next to Symbol opens a gallery of the Windows symbol font that you can search by code (E80F) or name (house); Enter picks the first match.

To add entries that depend on the user when the form opens:

Private Sub Form_Load()
    With Me!navMain.Object
        If IsAdmin() Then                         ' your own check
            .AddGroup "admin", "Administration"
            .AddItem "users", "Users", "E716", "admin"
            .AddItem "audit", "Audit log", "E81C", "admin"
        End If
        .ItemEnabled("reports") = DCount("*", "tblReports") > 0
    End With
End Sub

To copy the entries of one bar to another:

Forms!frmShell2!navMain.Object.Items = Forms!frmShell!navMain.Object.Items

Remarks

  • Keys are unique and not case-sensitive. In code, an empty key or an invalid symbol code raises wkeInvalidValue, a duplicate key raises wkeDuplicateKey, and an unknown group raises wkeKeyNotFound. In the designer, such entries keep the window open, and the problem is described.
  • Entries at the bottom edge have no group. Removing a group in the designer keeps its entries, ungrouped at the top; RemoveGroup in code removes them along with the group.
  • A symbol that exists only in Segoe Fluent Icons (Windows 11) stays empty on Windows 10; the gallery shows the symbols of the font installed on the computer it runs on.
  • Changes made at run time aren't saved with the form and aren't part of the user state.
en/wiki/msaccess/comctl/how-to/design-the-navigation-entries.txt · Last modified: by Wolfgang van der Stille