Color scheme: Riviera
You are here: start » en » Documentation » Microsoft Access development tools » WKL Forms Object Library » Layout » WklSplitter and WklDockLayout » Build an administration form with a dock layout

Build an administration form with a dock layout

In this tutorial, you place three areas (a customer list, the selected customer's record, and that customer's orders) on a form with a title in the form header, let a WklDockLayout arrange them across the whole window, and then work with the arrangement in Form view: dragging, collapsing, using the keyboard, and getting each user's own arrangement back. It takes about ten minutes and needs no VBA except for one optional button.

Prerequisites

  • Access in Microsoft 365 or the Access Runtime, 32-bit or 64-bit, with the WKL Forms Object Library 1.23 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 the sample tables

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 "CREATE TABLE tblOrders (OrderID COUNTER PRIMARY KEY, CustomerID LONG, Item TEXT(50), Quantity LONG)"
CurrentDb.Execute "INSERT INTO tblCustomers (Company, City) VALUES ('Adams Supply', 'Boston')"
CurrentDb.Execute "INSERT INTO tblCustomers (Company, City) VALUES ('Baker Tools', 'Chicago')"
CurrentDb.Execute "INSERT INTO tblOrders (CustomerID, Item, Quantity) VALUES (1, 'Screws', 100)"
CurrentDb.Execute "INSERT INTO tblOrders (CustomerID, Item, Quantity) VALUES (2, 'Nuts', 50)"

2. Lay out the areas roughly

Create a form bound to tblCustomers, set Default View to Single Form, save it as frmAdmin, and stay in Design view. Right-click the form, choose Form Header/Footer, and put a label with a title in the header.

In the Detail section, place three areas next to each other. The positions don't need to be exact, but each area should touch the edges it belongs to:

ControlNameWhereSettings
List boxlstCustomersalong the whole left edge, about 4 cm wideRow Source tblCustomers, Bound Column 1
SubformsfOrdersalong the bottom edge right of the list, about 3 cm highSource Object Table.tblOrders, Link Master Fields CustomerID, Link Child Fields CustomerID
SubformsfCustomerthe rest, above sfOrdersSource Object Table.tblCustomers

Leave the anchors of the three areas at Top Left.

3. Insert the dock layout

Choose Form Design › Controls › ActiveX Controls, select WKL Dock Layout, click OK, and draw the control over all three areas. Name it Layout1 and choose Arrange › Send to Back, so that the areas lie in front of it.

4. Check the areas in the designer

Select Layout1, open the property sheet, select the Other tab, and click [...] in the Custom row. The Areas page lists the areas the layout found by position, in docking order: lstCustomers (Left), sfOrders (Bottom), and sfCustomer (Fill); the preview on the right shows them filling the whole Detail section. Leave Fill the whole area and Set up on applying selected, and click OK. In Design view, the three areas are now arranged the way the form will show them, and the splitter bars have closed the gaps you left. Save the form.

The layout leaves the Panes list empty, because it finds the areas by position each time the form opens. To store fixed names and zones instead, click Take over by position before you click OK.

5. Work with the form

Open frmAdmin in form view:

  1. Make the Access window larger and smaller. At every size, the three areas fill the space between the header and footer; the list keeps its width, and the orders keep their height.
  2. Drag the splitter bar to the right of the list toward the right. A semi-transparent bar follows the mouse, and the areas move once when you release the button. Pressing Esc while dragging cancels the move.
  3. Double-click the splitter bar above the orders. The orders collapse and the customer record takes up the space; the bar stays at the bottom edge. Double-click it again to expand the orders.
  4. Click in the list and press F6 a few times; the focus moves from area to area. Press Tab until the splitter bar to the right of the list has the focus (it turns darker), then use the arrow keys to resize the list and Enter to collapse it.
  5. Close the form and open it again. The arrangement from step 2 comes back; it's stored for your Windows user account in the USysWklLayout table (a system table that's hidden in the Navigation Pane).

6. Give the user the design back (optional)

Add a cmdDefaultLayout button to the form header with this Click event procedure:

Private Sub cmdDefaultLayout_Click()
    Me!Layout1.Object.Reset
End Sub

Reset restores the designed sizes and removes the remembered arrangement.

Expected result

An administration form whose areas use the whole window at every size, which users can resize and collapse with the mouse or keyboard, and which opens with each user's own arrangement, all without code except for the optional reset button. An arrangement never changes the form's design.

Next steps

en/wiki/msaccess/comctl/layout/dock-layout-and-splitter/tutorial.txt · Last modified: by Wolfgang van der Stille