WklDrawer
WklDrawer class
Signature
Dim myWklDrawer As WklDrawer Set myWklDrawer = Me!ControlName.Object
Summary
A panel at the right edge of a form beside a list: a subform control shows its content, and opening it makes the list narrower instead of covering it.
Parameters
None
Remarks
Place three things side by side on the form: the list (or any controls) on the left, the drawer control as a narrow vertical bar, and a subform control on the right whose name goes into Content. The drawer control is the grip bar between them. When the drawer opens, the list becomes narrower and the panel takes its width at the right edge; when it closes, panel and bar disappear and the list takes the whole width again. Nothing is covered, so the list stays usable while the panel shows the record selected in it - an edit form, a wizard or a matrix.
The state when the form opens is the design: a visible subform control means the drawer is open. Open and Close change it at run time; Open can switch the content in the same call (Open "frmPersonEdit"), and the focus goes into the content.
The width belongs to the content: a width the user dragged to is remembered per content and Windows user (AutoSaveLayout), then the width designed for the content in Widths, then Width. MinWidth, MaxWidth and MinBeside limit it; in a narrow window the controls beside keep MinBeside and the panel gets the rest, it never falls back to a dialog. With FillForm (default) the right edge follows the visible width of the form when the window changes size.
Access applies the anchors of the controls of a form shown in a subform control only when the Access window changes size, not when the width of the subform control is set by code, as the drawer does when it opens or is dragged. With AnchorContent (default) the drawer does it: set HorizontalAnchor and VerticalAnchor in the design of the content form as usual, and titles, text boxes and grids follow the width of the panel. The drawer takes the anchors over when a content loads (it sets them to left/top and places the controls itself); design the content form without a horizontal scroll bar, because Access lets a form grow but not shrink at run time.
Open, Close, Toggle, IsOpen, SourceObject (setting it) and Arrange act only in form view and raise wkeNotAvailable in design view.
An ActiveX control: inserted into a form in design view (Form Design › Controls › ActiveX Controls); reports are not supported. VBA reaches it through the Object property of the control, where ControlName is the name of the control on the form.
| Member | Kind | Summary |
|---|---|---|
| `Content` | Property | Gets or sets the name of the subform control that shows the content of the panel. |
| `BesideControls` | Property | Gets or sets the names of the controls that become narrower when the panel opens. |
| `SourceObject` | Property | Gets or sets the content of the panel: the SourceObject of the subform control named in Content. |
| `Width` | Property | Gets or sets the width of the panel in twips. |
| `MinWidth` | Property | Gets or sets the smallest width of the panel in twips. |
| `MaxWidth` | Property | Gets or sets the largest width of the panel in twips. |
| `MinBeside` | Property | Gets or sets the smallest width the controls beside the panel keep, in twips. |
| `Widths` | Property | Gets or sets the width of the panel per content as JSON. |
| `Resizable` | Property | Gets or sets whether the user drags the bar to make the panel wider or narrower. |
| `IsOpen` | Property | Gets or sets whether the panel is open. |
| `AutoSaveLayout` | Property | Gets or sets whether the width the user dragged to is remembered per content and Windows user. |
| `LayoutKey` | Property | Gets or sets the name the widths are remembered under. |
| `FillForm` | Property | Gets or sets whether the right edge of the panel follows the visible width of the form. |
| `CloseOnEscape` | Property | Gets or sets whether Esc closes the panel. |
| `CloseButton` | Property | Gets or sets whether the bar shows a close button at its top. |
| `BackColor` | Property | Gets or sets the color of the bar. |
| `AnchorContent` | Property | Gets or sets whether the controls of the content follow their anchors when the panel changes size. |
| `Open` | Method | Opens the panel, optionally with a new content; the focus goes into the content. |
| `Close` | Method | Closes the panel; the controls beside it take the whole width again. |
| `Toggle` | Method | Opens the closed and closes the open panel. |
| `Arrange` | Method | Reads the list and the panel anew from the form and arranges them again. |
| `ColorScheme` | Property | Gets or sets the color scheme the control draws in. |
| Event | Summary |
|---|---|
| `BeforeOpen` | Occurs before the panel opens. |
| `AfterOpen` | Occurs after the panel opened. |
| `BeforeClose` | Occurs before the panel closes. |
| `Closed` | Occurs after the panel closed; the controls beside have the whole width again. |
| `AfterResize` | Occurs after the user changed the width with the bar. |
Code example
' The edit form of the selected person beside the list; the list stays usable.
Private Sub lstPersons_AfterUpdate()
With Me!drwEdit.Object
If Not .IsOpen Then .Open "frmPersonEdit"
End With
Me!sfEdit.Form.Filter = "PersonId = " & Me!lstPersons
Me!sfEdit.Form.FilterOn = True
End Sub
Private Sub drwEdit_Closed(ByVal Reason As WklDrawerCloseReason)
Me!lstPersons.SetFocus
End Sub
Inheritance
None
Content property
Signature
Property Get Content() As String Property Let Content(RHS As String)
Summary
Gets or sets the name of the subform control that shows the content of the panel.
Parameters
None
Property value: String – The name of a subform control of the same section.
Remarks
A name the form does not have raises wkeNotConfigured when the drawer first arranges or when code opens it.
Read/write.
Code example
None
Inheritance
Declared by WklDrawer.
BesideControls property
Signature
Property Get BesideControls() As String Property Let BesideControls(RHS As String)
Summary
Gets or sets the names of the controls that become narrower when the panel opens.
Parameters
None
Property value: String – Control names separated by semicolons; empty (default): every visible control whose right edge lies left of the bar and which shares rows with it.
Remarks
Each control keeps its own gap to the bar of the design. A name the form does not have raises wkeInvalidValue when the drawer first arranges.
Read/write.
Code example
None
Inheritance
Declared by WklDrawer.
SourceObject property
Signature
Property Get SourceObject() As String Property Let SourceObject(RHS As String)
Summary
Gets or sets the content of the panel: the SourceObject of the subform control named in Content.
Parameters
None
Property value: String – A form name (frmPersonEdit or Form.frmPersonEdit), Table.Name or Query.Name.
Remarks
Setting it switches the content; while the panel is open it takes the width of the new content. Reading returns the value as Access stores it.
Read/write.
Code example
None
Inheritance
Declared by WklDrawer.
Width property
Signature
Property Get Width() As Long Property Let Width(RHS As Long)
Summary
Gets or sets the width of the panel in twips.
Parameters
None
Property value: Long – While the panel is open in form view, its current width; otherwise the width for a content without a width of its own in Widths (default 4536, 8 cm).
Remarks
Setting it while the panel is open resizes the panel now and forgets the width the user dragged to for this content.
Read/write.
Code example
None
Inheritance
Declared by WklDrawer.
MinWidth property
Signature
Property Get MinWidth() As Long Property Let MinWidth(RHS As Long)
Summary
Gets or sets the smallest width of the panel in twips.
Parameters
None
Property value: Long – 0 (default) for no limit.
Remarks
Read/write.
Code example
None
Inheritance
Declared by WklDrawer.
MaxWidth property
Signature
Property Get MaxWidth() As Long Property Let MaxWidth(RHS As Long)
Summary
Gets or sets the largest width of the panel in twips.
Parameters
None
Property value: Long – 0 (default) for no limit.
Remarks
Read/write.
Code example
None
Inheritance
Declared by WklDrawer.
MinBeside property
Signature
Property Get MinBeside() As Long Property Let MinBeside(RHS As Long)
Summary
Gets or sets the smallest width the controls beside the panel keep, in twips.
Parameters
None
Property value: Long – 0 (default) for no limit; for a wide content such as a matrix, for example 3402 (6 cm), so that a strip of the list stays visible.
Remarks
Read/write.
Code example
None
Inheritance
Declared by WklDrawer.
Widths property
Signature
Property Get Widths() As String Property Let Widths(RHS As String)
Summary
Gets or sets the width of the panel per content as JSON.
Parameters
None
Property value: String – A JSON object of widths in twips per content, for example {"frmPersonEdit": 4500, "frmRightsMatrix": 16000}; empty (default) for none.
Remarks
Every spelling of a form names the same content (frmPersonEdit, Form.frmPersonEdit); tables and queries use Table.Name and Query.Name. A text that is no JSON object of positive whole numbers raises wkeInvalidValue.
Read/write.
Code example
None
Inheritance
Declared by WklDrawer.
Resizable property
Signature
Property Get Resizable() As Boolean Property Let Resizable(RHS As Boolean)
Summary
Gets or sets whether the user drags the bar to make the panel wider or narrower.
Parameters
None
Property value: Boolean – True (default) or False.
Remarks
While dragging, a half-transparent bar follows the mouse; the controls move once, when the button is released, and AfterResize follows. Esc cancels the drag.
Read/write.
Code example
None
Inheritance
Declared by WklDrawer.
IsOpen property
Signature
Property Get IsOpen() As Boolean Property Let IsOpen(RHS As Boolean)
Summary
Gets or sets whether the panel is open.
Parameters
None
Property value: Boolean – True while the panel is open; setting it opens or closes the panel as Open and Close do.
Remarks
Read/write.
Code example
None
Inheritance
Declared by WklDrawer.
AutoSaveLayout property
Signature
Property Get AutoSaveLayout() As Boolean Property Let AutoSaveLayout(RHS As Boolean)
Summary
Gets or sets whether the width the user dragged to is remembered per content and Windows user.
Parameters
None
Property value: Boolean – True (default) or False.
Remarks
In Access the widths go into the local table USysWklLayout, as for WklSplitter and WklDockLayout.
Read/write.
Code example
None
Inheritance
Declared by WklDrawer.
LayoutKey property
Signature
Property Get LayoutKey() As String Property Let LayoutKey(RHS As String)
Summary
Gets or sets the name the widths are remembered under.
Parameters
None
Property value: String – Empty (default) for “form name.control name”.
Remarks
Read/write.
Code example
None
Inheritance
Declared by WklDrawer.
FillForm property
Signature
Property Get FillForm() As Boolean Property Let FillForm(RHS As Boolean)
Summary
Gets or sets whether the right edge of the panel follows the visible width of the form.
Parameters
None
Property value: Boolean – True (default): when the window changes size, the panel keeps its distance to the right edge of the form as designed and the controls beside take the change; False: the area stays as designed.
Remarks
Read/write.
Code example
None
Inheritance
Declared by WklDrawer.
CloseOnEscape property
Signature
Property Get CloseOnEscape() As Boolean Property Let CloseOnEscape(RHS As Boolean)
Summary
Gets or sets whether Esc closes the panel.
Parameters
None
Property value: Boolean – False (default) or True.
Remarks
Esc closes the panel only while its content has no changed record: in an Access form Esc first undoes a change. Closing raises BeforeClose and Closed with wdcEscape.
Read/write.
Code example
None
Inheritance
Declared by WklDrawer.
CloseButton property
Signature
Property Get CloseButton() As Boolean Property Let CloseButton(RHS As Boolean)
Summary
Gets or sets whether the bar shows a close button at its top.
Parameters
None
Property value: Boolean – True (default) or False.
Remarks
A click on it closes the panel with wdcUser.
Read/write.
Code example
None
Inheritance
Declared by WklDrawer.
BackColor property
Signature
Property Get BackColor() As OLE_COLOR Property Let BackColor(RHS As OLE_COLOR)
Summary
Gets or sets the color of the bar.
Parameters
None
Property value: OLE_COLOR – An OLE color; default the system color of a button face, which follows ColorScheme.
Remarks
Read/write.
Code example
None
Inheritance
Declared by WklDrawer.
AnchorContent property
Signature
Property Get AnchorContent() As Boolean Property Let AnchorContent(RHS As Boolean)
Summary
Gets or sets whether the controls of the content follow their anchors when the panel changes size.
Parameters
None
Property value: Boolean – True (default) or False.
Remarks
See the remarks of WklDrawer for why the drawer applies the anchors itself and why the content form should have no horizontal scroll bar.
Read/write.
Code example
None
Inheritance
Declared by WklDrawer.
Open method
Signature
Sub Open(Optional ByVal SourceObject As Variant)
Summary
Opens the panel, optionally with a new content; the focus goes into the content.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
SourceObject | Variant | Yes | – | Optional; the content to show (as SourceObject); omitted: the content stays. |
Remarks
BeforeOpen may cancel; AfterOpen follows. Opening an open panel with another content switches the content.
Code example
None
Inheritance
Declared by WklDrawer.
Close method
Signature
Sub Close()
Summary
Closes the panel; the controls beside it take the whole width again.
Parameters
None
Remarks
BeforeClose may cancel; Closed follows with wdcCode. The focus moves to a control beside the panel first, because Access does not hide the control that has the focus.
Code example
None
Inheritance
Declared by WklDrawer.
Toggle method
Signature
Sub Toggle()
Summary
Opens the closed and closes the open panel.
Parameters
None
Remarks
None
Code example
None
Inheritance
Declared by WklDrawer.
Arrange method
Signature
Sub Arrange()
Summary
Reads the list and the panel anew from the form and arranges them again.
Parameters
None
Remarks
Call it after code moved or resized the controls of the drawer; the drawer otherwise computes from the design it read when it first arranged.
What Arrange reads anew and what it keeps:
- Read anew: the positions and heights of the bar, the content and the controls beside, and the right margin of the area (the width of the section minus the right edge of the area). The drawer never changes heights; a page that follows the window height sets the heights of list, bar and content itself and then calls
Arrange. - Kept: the current width of the content control, the widths per content (
Widths) and the widths the user dragged to (AutoSaveLayout). - Closed drawer:
Arrangeonly reads the positions; opening arranges with them.
With FillForm (the default) the open drawer already follows the visible width of the form every 300 ms. Code that also sets the width of the area handles the width twice: either keep FillForm and set only the heights before Arrange, or turn FillForm off and set heights and widths before Arrange.
Code example
None
Inheritance
Declared by WklDrawer.
ColorScheme property
Signature
Property Get ColorScheme() As WklColorScheme Property Let ColorScheme(RHS As WklColorScheme)
Summary
Gets or sets the color scheme the control draws in.
Parameters
None
Property value: `WklColorScheme` – wcoAutomatic (default), wcoLight, wcoDark or wcoHighContrast.
Remarks
The scheme colors the bar (while BackColor keeps the system default), its grip dots and the close button. wcoAutomatic follows Windows high contrast mode, then the color set of the database design, else light. The value is saved with the form.
Read/write.
Code example
None
Inheritance
Declared by WklDrawer.
BeforeOpen event
Signature
Event BeforeOpen(ByVal SourceObject As String, ByRef Cancel As Integer)
Summary
Occurs before the panel opens.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
SourceObject | String | No | – | The content that will show. |
Cancel | Integer (by reference) | No | – | Set to True to leave the panel closed. |
Remarks
In a form module: Private Sub <ControlName>_BeforeOpen(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklDrawer.
AfterOpen event
Signature
Event AfterOpen(ByVal SourceObject As String)
Summary
Occurs after the panel opened.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
SourceObject | String | No | – | The content it shows. |
Remarks
In a form module: Private Sub <ControlName>_AfterOpen(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklDrawer.
BeforeClose event
Signature
Event BeforeClose(ByVal Reason As WklDrawerCloseReason, ByRef Cancel As Integer)
Summary
Occurs before the panel closes.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Reason | `WklDrawerCloseReason` | No | – | Who closes it. |
Cancel | Integer (by reference) | No | – | Set to True to leave the panel open. |
Remarks
In a form module: Private Sub <ControlName>_BeforeClose(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklDrawer.
Closed event
Signature
Event Closed(ByVal Reason As WklDrawerCloseReason)
Summary
Occurs after the panel closed; the controls beside have the whole width again.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Reason | `WklDrawerCloseReason` | No | – | Who closed it. |
Remarks
In a form module: Private Sub <ControlName>_Closed(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklDrawer.
AfterResize event
Signature
Event AfterResize(ByVal Width As Long)
Summary
Occurs after the user changed the width with the bar.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Width | Long | No | – | The new width in twips. |
Remarks
In a form module: Private Sub <ControlName>_AfterResize(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklDrawer.