Farbschema: Riviera
Sie befinden sich hier: start » en » Documentation » Microsoft Access development tools » WKL Forms Object Library » Navigation and commands » WklNavBar » Build a navigation shell

Build a navigation shell

In this tutorial, you build a shell form with a WklNavBar on the left and a page subform that fills the rest, both arranged by a WklDockLayout. You design the entries without code, a single event procedure swaps the page, and a badge shows a count. It takes about fifteen minutes.

Prerequisites

  • Access in Microsoft 365 or the Access Runtime, 32-bit or 64-bit, with the WKL Forms Object Library 1.24 or later installed and registered for the current Windows user (How to: Install the released package).
  • A new database in a trusted location.
  • Every WKL control opens its designer the same way: in Design view, open the property sheet (F4), select the Other tab, and click [...] in the Custom row (How to: Open the designer of a control).

Steps

1. Create a table and two pages

Run these lines one at a time in the Immediate window (Ctrl+G):

CurrentDb.Execute "CREATE TABLE tblCustomers (CustomerID COUNTER PRIMARY KEY, Company TEXT(50), City TEXT(50))"
CurrentDb.Execute "INSERT INTO tblCustomers (Company, City) VALUES ('Adams Supply', 'Boston')"
CurrentDb.Execute "INSERT INTO tblCustomers (Company, City) VALUES ('Baker Tools', 'Chicago')"

Select tblCustomers in the Navigation Pane and choose Create › Form; save the form as frmCustomers. Choose Create › Blank Form, add a label that says „Welcome,“ and save the form as frmStart. These are the pages the shell shows.

2. Lay out the shell

Create a form in Design view, set Default View to Single Form, set Record Selectors and Navigation Buttons to No, and save the form as frmShell. In the Detail section:

  1. Choose Form Design › Controls › ActiveX Controls, select WKL Navigation Bar, click OK, and draw the control along the entire left edge, about 2.5 in. wide. Name it navMain.
  2. Draw a subform control over the rest of the section, name it sfPage, and set its Source Object to Form.frmStart.
  3. Insert a WKL Dock Layout the same way, draw it over both controls, name it Layout1, and choose Arrange › Send to Back.

Leave the anchors of navMain and sfPage at Top Left. In the property sheet for Layout1, select the Other tab, click [...] in the Custom row, and on the Areas page check that the layout found navMain (Left) and sfPage (Fill); then click OK.

3. Design the entries

Select navMain and click [...] in the Custom row of the property sheet. On the Entries page:

  1. Click Entry. In the fields below the list, set Key to start and Caption to Home, then click Choose … next to Symbol, type house, and press Enter. Turn on Selected on opening.
  2. Click Group, and set Key to data and Caption to Data.
  3. With the group selected, click Entry: Key customers, Caption Customers, symbol people (search for people).
  4. Click Entry again, set Key to settings, Caption to Settings, and the symbol to gear, and then choose At the bottom edge under Place.

The preview shows the bar both expanded and as the icon column. Click OK and save the form.

4. Swap the page in Navigate

Open the form's module (Form Design › View Code) and add:

Private Sub navMain_Navigate(ByVal Key As String)
    Select Case Key
        Case "start": Me!sfPage.SourceObject = "Form.frmStart"
        Case "customers": Me!sfPage.SourceObject = "Form.frmCustomers"
        Case "settings": MsgBox "Settings"
    End Select
End Sub
 
Private Sub Form_Load()
    ' Badges are run-time values: set them whenever the form opens.
    Me!navMain.Object.SetBadge "customers", DCount("*", "tblCustomers"), wskInfo
End Sub

5. Use the shell

Open frmShell in Form view and try the following:

  • Click Customers. The page shows the customers, and the entry is highlighted.
  • Click the toggle button (three lines) or press Ctrl+B. The bar collapses to the icon column and the page gets wider; do it again, and the bar expands. Ctrl+B also works while a field on the page has the focus.
  • Drag the splitter bar between the navigation bar and the page; the expanded bar gets wider.
  • Press Tab to move to the bar, then use the arrow keys and Enter.
  • Close the form and open it again. The mode and width are just as you left them.

Expected result

A shell whose page changes with the entry the user chooses, a bar that switches between captions and icons and remembers each user's choice, a badge with the number of customers, and no code except the Navigate procedure and the badge.

Next steps

en/wiki/msaccess/comctl/navigation-and-commands/navbar/tutorial.txt · Zuletzt geändert: von Wolfgang van der Stille