WklNavBar
WklNavBar is the navigation bar for administration front ends in Access: either a narrow column
of symbols or a wide bar with captions and group headers, with entries along the top and bottom
edges, count badges, and one selected entry. When the user picks an entry, the application responds
in the Navigate event, usually by showing a different form in a subform. Alternatively, the bar
reads its entries and their pages from a table and displays the pages itself.
Get started
Common tasks
Visual aid
+- frmShell ---------------------------------------------------------------+
| Form header: title, search |
+-----------------------+-+------------------------------------------------+
| [=] [1] |#| sfPage [5] |
| (H) Home |#| |
| DATA v |#| |
| |(T) Tables 4 |#| the page of the chosen entry |
| (S) Sessions (3) [2]|#| |
| OPERATIONS > |#| |
| |#| |
|-----------------------|#| |
| (*) Settings [3] |#| |
+-----------------------+-+------------------------------------------------+
[4]
+---+ icon column (Mode = compact) +---+---------------------+
|[=]| |[=]| (H) Home | overlay (Pinned = False):
|(H)| |(H)| DATA | the expanded bar lies over
|(T)4 |(T)| (T) Tables 4 | the page until an entry is
|(S)3 |(S)| ... | chosen [6]
+---+ +---+---------------------+
| Region | Meaning |
|---|---|
| 1 | Toggle button: switches between the expanded bar and the symbol column (ShowToggle); ToggleShortcut (Ctrl+B by default) does the same from anywhere on the form |
| 2 | Group header (collapses its entries) and entries with symbol and caption; an accent bar marks the selected entry, and badges show a count or a dot |
| 3 | Entries at the bottom edge (settings, help): they belong to no group and stay visible when the list scrolls |
| 4 | Splitter of the WklDockLayout that holds the bar as one of its areas: the user drags it to make the bar wider or narrower |
| 5 | The page: a subform whose SourceObject the application sets in Navigate; for entries with a subform target (TargetControl), the bar sets it itself |
| 6 | When unpinned, the bar takes up only the width of the symbol column; when expanded, it overlays the page |
Key features
- Three modes: expanded (symbols, captions, group headers), a 48-pixel symbol column, or hidden. Users switch with the toggle button or
ToggleShortcut, andModeChangedreports each change. - Pinned or overlay (
Pinned): when pinned, the expanded bar sits next to the page at full width. When unpinned, it stays as narrow as the symbol column and expands over the page, then closes as soon as the user picks an entry, presses Esc, or clicks elsewhere. - Groups and entries are designed with the form (designer: Custom row,
[...]) or added in code (AddGroup,AddItem,Items). You can hide or disable each entry individually, and users can collapse groups. - Entries and pages from a table (
RecordSource,KeyField, …): groups and entries come from a table, query, or SQL statement. Each entry can have a target (a page shown in a subform control, or a form or report opened in its own window), and a start page appears when the form opens. Before the bar replaces a page that has unsaved changes, it asks the user. It keeps the active form highlighted among its form targets and reports faulty rows inLoadProblemsinstead of rejecting the whole table. The designer can create a matching template table from the designed entries. - Badges (
SetBadge): a count or a dot in the color of a status kind. The application sets them at run time; they are never saved with the form. - No event loops: only user actions raise events. When code selects the entry for the page it has just opened (
SelectedKey), nothing fires.BeforeNavigatecan cancel a choice, for example while the open page has unsaved changes. - Width in a
WklDockLayout: when the bar is an area of a layout, it sizes that area itself and adopts the width the user drags the splitter to. Outside a layout, it resizes itself and provides its own drag edge. - State remembered per Windows user (
AutoSaveLayout): the bar stores mode, width, and collapsed groups in the localUSysWklLayouttable of the front end, or in the registry on UserForms.Resetrestores the design. - Keyboard and screen readers: the bar is a single tab stop, and inside it the arrow keys, Home, End, Enter, and Space work. The shortcut also works in subforms. UI Automation exposes the bar as a list named “Navigation” with groups and entries; the badge is part of the entry's name.
Core concepts
The bar navigates; the page belongs to the application, or to the table. The bar tracks the
selected entry and raises BeforeNavigate and Navigate with its key. In a designed bar, the
application's code decides what a key means: a subform's SourceObject, a form to open, or a
filter. A bound bar reads each entry's target from its table and displays it between
BeforeNavigate and Navigate; entries without a target still leave everything to Navigate.
Swapping the SourceObject of the page subform doesn't disturb the bar or the surrounding layout:
sizes, collapsed areas, and positions stay the same even after hundreds of swaps.
A table replaces the design without overwriting it. A bound bar shows the rows of its table
instead of the designed entries. The designed entries remain saved with the form (Items) and come
back if the source can't be read or you remove the binding.
Design and user state are separate. Groups, entries, the entry selected when the form opens,
mode, pinning, and width make up the design and are saved with the form. Changes the user makes to
mode, width, and collapsed groups are user state: saved per Windows user, restored once when the
form first appears, and reset to the design by Reset. Badges and the run-time selection belong to
neither; the application sets them when the form opens.
User actions and changes from code. Clicks, Enter, Space, the shortcut, and UI Automation calls
count as user actions and raise BeforeNavigate, Navigate, and ModeChanged. Properties and
methods called from code change the bar without raising events.
Single forms and UserForms. The bar belongs on a single form, because Access doesn't repeat ActiveX controls for each record of a continuous form. It also works on UserForms in Excel and Word, where the shortcut works only while the bar has the focus.
Administration
Troubleshooting
For developers
Related topics
- WklSplitter and WklDockLayout: the layout that usually holds the bar