Color scheme: Dark
You are here: start » en » Documentation » Microsoft Access development tools » WKL Forms Object Library » WKL Forms Object Library how-to guides » How to: Set the content of layout areas in the designer

How to: Set the content of layout areas in the designer

Choose what the subforms in a WklDockLayout show, and add new areas, from the layout's designer instead of drawing subform controls and filling in their property sheets one at a time.

Requires WKL Forms Object Library 1.37 or later.

Solution overview

The designer's Contents page lists every subform control on the form with its source object (SourceObject): a form, table, or query in the database. The New area card adds a subform control with a name, a zone, and a source object. Nothing is written while the designer is open. When you click OK or Apply, the designer closes, and the layout then changes the form in this order: new subform controls first, then the source objects, and then, when Set up on applying is on, the placement fix (anchors, order, and moving the areas in Design view to where Form view shows them). Save the form afterward, as after any change in Design view.

Implementation

  1. Open the form in Design view, select the layout control, open the property sheet, select the Other tab, and click [...] in the Custom row.
  2. Select the Contents page. The Source objects grid has one row for each subform control. Change the source object in the Source object column; the list offers forms, then tables, then queries, each in alphabetical order and spelled as in the property sheet (in English Access, Table.tblItems and Query.qryOpen). (empty) removes the source object.
  3. To add an area, fill in the New area card:
    • Name: the name of the new subform control.
    • Zone: Left, Top, Right, Bottom, or Fill.
    • Source object: what the new subform shows, or (empty).

      Then click Create area. This also turns on Set up on applying (on the Areas page), so the new area is arranged with the others when you click OK. The area appears right away in the list on the Areas page and in the preview, with its source object after its name.

  4. Click OK, and then save the form.

To make the same changes in code, in Design view and without the designer:

' Design view of frmAdmin is open. A new subform at the right edge, and a query in sfInfo.
Dim c As Control
Set c = CreateControl("frmAdmin", acSubform, acDetail, , , 9000, 0, 2400, 5000)
c.Name = "sfAudit"
c.SourceObject = "frmAudit"
Forms!frmAdmin!sfInfo.SourceObject = "Query.qryOpen"
Forms!frmAdmin!Layout1.Object.Panes = "lstCustomers=Left; sfAudit=Right; sfInfo=Fill"

Access accepts Table.<name> and Query.<name> for SourceObject in code, and returns the spelling of its own user interface language when the property is read; for example, German Access returns Abfrage.qryOpen for Query.qryOpen. Compare the values you read with both spellings.

Remarks

  • The page lists only subform controls; other areas (list boxes and WKL controls) keep their content.
  • A new area needs an unused name: letters, digits, and _, starting with a letter, up to 64 characters, and not used by any other control on the form (or by the layout itself). The page's info bar explains why a name is rejected.
  • A new area is placed at the edge of its zone inside the layout's rectangle, taking a quarter of the layout's width (left or right) or height (top or bottom), and at least 0.79 in. (1,134 twips); a fill area takes up the layout's rectangle. When the form opens, the layout arranges it like any other area.
  • When the list on the Areas page is empty (areas found by position), adding an area first writes out the areas found by position, so the new one joins them in docking order; the layout then uses that list instead of finding areas by position.
  • You can add areas and set contents only in Design view of an Access form; on a UserForm, the page says so, and Create area shows a message and does nothing.
  • Removing a row on the Areas page that was added with Create area and hasn't been written yet also discards the new area.
  • The changes are made after the designer has closed, outside the property sheet. If Access rejects one of them, a message box over the Access window gives the reason, and the form keeps the changes made up to that point.
en/wiki/msaccess/comctl/how-to/set-the-content-of-layout-areas.txt · Last modified: by Wolfgang van der Stille