WklTreeList
WklTreeList class
Signature
Dim myWklTreeList As WklTreeList Set myWklTreeList = Me!ControlName.Object
Summary
A hierarchical datasheet: a tree with columns, bands, cell editors, conditional formatting and footer totals.
Parameters
None
Remarks
WklTreeList has every member and event of `WklTreeView`: binding, loading, writing back, search, filter, check marks. It adds columns (Columns), multi-level headers and multi-row records (Bands), conditional formatting (FormatRules), footer totals, cell editing, grouping of flat records (GroupFields) and export.
Columns, bands and rules set in design view are saved with the form in ColumnLayout. The designer window (property sheet: Custom [...]) edits them without VBA.
The grid supports UI Automation: screen readers and test tools see a data grid with column headers, one item per record with its level and position in the tree, and cells with their displayed text.
The shortcut menu of a node (right mouse button, the menu key or Shift+F10; with ContextMenu = False only the custom entries):
| Entry | Shown or enabled | Key shown |
|---|---|---|
| Aufklappen, Zuklappen, Alle Unterknoten aufklappen, Alle zuklappen | as in WklTreeView | + / - / * |
| Edit cell | on a cell; enabled with AllowEditing for a column that is not read-only | F2 |
| Ascending by „…“, Descending by „…“, Remove sorting, Best fit | on a cell | |
| New node here, New node below | AllowAdditions; enabled without GroupFields (CanAdd) | Ins / Ctrl+Ins |
| Delete | AllowDeletions; not on a group node (CanDelete) | Del |
| Copy | always (not on a group node unless several nodes are selected) | Ctrl+C |
| Refresh | always | F5 |
| Search | AllowSearch | Ctrl+F |
| Export … | AllowExport | |
custom entries (AddMenuItem) | after a separator |
Keys are those of `WklGrid` with the tree's own: → expands a collapsed node, ← collapses it or goes to its parent, + / - on the numeric keypad expand and collapse, * expands the whole subtree, Spacebar switches the check box of the node (CheckBoxes), Ins and Ctrl+Ins add a node (AllowAdditions); Ctrl++ adds a node after the focused one and Ctrl+- deletes the selected nodes, as in an Access datasheet (NewRecord, DeleteSelected). Renaming, cutting, pasting and moving nodes by key are features of WklTreeView; the tree list edits its cells instead.
The tree list reads one record source for all levels (see RecordSource): parents and children from different tables need one query that returns both, usually a UNION query, which Access cannot update - set AllowEditing, AllowAdditions and AllowDeletions to False for it. Access applies the anchors of a page's controls (a form in a subform control) when the Access window changes size, not when the page's width is set by code; a WKL control anchored left and right follows the page at once (see „Inside a page“ in Layout overview). Anchor the tree list left and right (and top and bottom) in the page's design to let it fill the page.
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 |
|---|---|---|
| `Columns` | Property | Returns the columns. |
| `Bands` | Property | Returns the bands of the header. |
| `FormatRules` | Property | Returns the conditional formatting rules. |
| `ColumnLayout` | Property | Gets or sets the columns, bands and format rules as text. |
| `TreeColumn` | Property | Gets or sets the column that holds the tree (indentation and expand buttons). |
| `ShowHeader` | Property | Gets or sets whether the column headers are shown. |
| `GridLines` | Property | Gets or sets the grid lines. |
| `ShowFooter` | Property | Gets or sets whether the footer with the column totals is shown. |
| `RowHeight` | Property | Gets or sets the height of a record row in twips. |
| `AlternateBackColor` | Property | Gets or sets the background color of every second row. |
| `AllowEditing` | Property | Gets or sets whether cells can be edited. |
| `FocusedColumn` | Property | Gets or sets the column of the focused cell. |
| `CellValue` | Property | Gets or sets the value of a cell. |
| `CellText` | Property | Returns the displayed text of a cell. |
| `SummaryValue` | Property | Returns the total of a column. |
| `BestFitColumns` | Method | Sets the width of every visible column to fit its header and contents. |
| `EditCell` | Method | Opens the editor of a cell in form view. |
| `GroupFields` | Property | Gets or sets the fields by which flat records are grouped into a tree. |
| `ExportToXlsx` | Method | Exports the list as an Excel workbook, without Excel. |
| `ExportToFile` | Method | Exports the list in a file format. |
| `ExportToXml` | Method | Exports the list as XML, without Excel: the columns, the records as a tree with their values, and the sums. |
| `ExportToJson` | Method | Exports the list as JSON, without Excel: the columns, the records as a tree with their values, and the sums. |
| `AllowExport` | Property | Gets or sets whether the shortcut menu offers Export …. |
| `ExportMode` | Property | Gets or sets how the context menu's export writes an Excel workbook. |
| `ExportRows` | Property | Gets or sets which records the context menu's export writes. |
| `NewRecord` | Method | Starts a new record as the user does with Ctrl++ or the shortcut menu. |
| `DeleteSelected` | Method | Deletes the selected records as the Delete key does. |
| `EditSelected` | Method | Opens the editor of the focused cell, or of the first editable cell of the focused record; with an edit form, opens the form for the focused record. |
| `CopySelected` | Method | Copies the focused cell, or the selected records with a header row, to the clipboard as Ctrl+C does. |
| `ShowExportDialog` | Method | Shows the export dialog of the shortcut menu: Excel workbook, XML or JSON file. |
| `ShowContextMenu` | Method | Opens the shortcut menu of the focused record below its focused cell, as the menu key does. |
| `CanAdd` | Property | Gets whether NewRecord can start a new record now. |
| `CanDelete` | Property | Gets whether DeleteSelected can delete now. |
| `CanEdit` | Property | Gets whether EditSelected can open a cell editor now. |
| `CanExport` | Property | Gets whether ShowExportDialog can show the export dialog. |
| `AutoSaveLayout` | Property | Gets or sets whether the user's arrangement of the columns is remembered per Windows user. |
| `LayoutKey` | Property | Gets or sets the name the arrangement is remembered under. |
| `Reset` | Method | Shows the columns, sorting, grouping, filters and detail height of the design again and removes the user's remembered arrangement. |
| `ShortcutMenuBar` | Property | Gets or sets the name of an Access shortcut menu bar whose entries the control's shortcut menu shows. |
| `MenuPlacement` | Property | Gets or sets where the own entries stand in the shortcut menu. |
| `ContextKey` | Property | Gets the key of the record the shortcut menu was last opened on. |
| `ContextColumn` | Property | Gets the column the shortcut menu was last opened on. |
| `ContextView` | Property | Gets the detail view the shortcut menu was last opened in. |
| `MenuItemEnabled` | Property | Gets or sets whether a custom menu item can be chosen. |
| `MenuItemChecked` | Property | Gets or sets whether a custom menu item shows a check mark. |
| `MenuItemGlyph` | Property | Gets or sets the glyph of a custom menu item. |
| `MenuItemShortcut` | Property | Gets or sets the key combination shown at a custom menu item. |
| `MenuItemParent` | Property | Gets or sets the custom menu item whose submenu holds an item. |
| `EditForm` | Property | Gets or sets the name of the Access form that edits a record of the list (the edit form). |
| `EditKeyFields` | Property | Gets or sets the fields of the edit form's record source that hold the parts of the list's key. |
| `EditFormMode` | Property | Gets or sets where the edit form is shown. |
| `EditKindField` | Property | Gets or sets the field of the record source that holds the kind of a record, for the edit forms per kind in EditForms. |
| `EditForms` | Property | Gets or sets the edit forms per kind of record, as JSON text. |
| `EditFormControl` | Property | Gets or sets the subform control of the list's own form that shows the edit form when EditFormMode is wfmDocked, wfmAuto or wfmOverlay. |
| `EditFormResult` | Property | Gets what became of the record of the edit form that was done last. |
| `EditFormNewKey` | Property | Gets the key of the record the edit form that was done last has added. |
| `EditFormWidth` | Property | Gets or sets the width of the overlaying edit form (wfmOverlay). |
| `NewRecordOfKind` | Method | Starts a new record of a kind in its edit form. |
| `CanAddKind` | Property | Gets whether NewRecordOfKind can start a record of a kind now. |
| `ValidateMode` | Property | Gets or sets when the rules of the columns are checked. |
| `SetError` | Method | Shows an error at a cell or at a record. |
| `ClearErrors` | Method | Removes the errors of a record, or every error. |
| `ErrorCount` | Property | Gets the number of errors shown. |
| `ErrorText` | Property | Gets the message of a cell or of a record. |
| `GoToFirstError` | Method | Selects the record of the first error and shows its cell. |
| `ErrorSummary` | Property | Gets the summary of the errors as the error bar shows it. |
| `EditOnClick` | Property | Gets or sets whether a single click into an editable cell opens its editor. |
| `ShowFilterRow` | Property | Gets or sets whether the filter row is shown below the column headers. |
| `ColumnFilter` | Property | Gets or sets the condition of one column, in the format of the filter row. |
| `ColumnFilterValues` | Property | Gets or sets the values of a column that pass the filter, as the value list in the column header selects them. |
| `ColumnFilterEnabled` | Property | Gets or sets whether the column filter applies. |
| `ColumnFilterText` | Property | Gets the conditions of the column filter as text, as the filter bar shows them. |
| `ClearColumnFilters` | Method | Removes every column condition. |
| `ShowFilterBar` | Property | Gets or sets whether the filter bar appears below the records while columns are filtered. |
| `FilterIncludesChildren` | Property | Gets or sets whether a node that meets the filter brings its child nodes along. |
| `AllowColumnFilter` | Property | Gets or sets whether the user can filter columns from their headers. |
| Event | Summary |
|---|---|
| `CellClick` | Occurs when the user clicks a cell. |
| `CellDblClick` | Occurs when the user double-clicks a cell. |
| `BeforeCellEdit` | Occurs before the editor of a cell opens. |
| `ValidateCell` | Occurs after the user entered a value, before it is saved. |
| `AfterCellUpdate` | Occurs after a cell value was saved. |
| `ColumnClick` | Occurs when the user clicks a column header, before the list is sorted by it. |
| `ColumnResize` | Occurs after the user changed the width of a column. |
| `ColumnMove` | Occurs after the user moved a column. |
| `CellFormat` | Occurs before a cell is shown, to format it. |
| `FocusedCellChange` | Occurs when the focused cell changes. |
| `CommandStateChange` | Occurs when CanAdd, CanDelete, CanEdit or CanExport has changed, so that the form can enable or disable its own buttons. |
| `BeforeContextMenu` | Occurs before the shortcut menu opens: after a right click, the menu key, Shift+F10 or ShowContextMenu, also in a detail view. |
| `BeforeEditForm` | Occurs before the edit form opens. |
| `AfterEditForm` | Occurs after the edit form has been closed and the list has read its records again. |
| `ValidationChange` | Occurs when the errors shown have changed. |
| `BeforeColumnFilter` | Occurs when the user changes the column filter, before the nodes are filtered. |
| `AfterColumnFilter` | Occurs after the user changed the column filter and the nodes were filtered. |
Code example
With Me!List1.Object
.RecordSource = "tblItems"
.KeyField = "ID": .ParentField = "ParentID": .TextField = "Name"
.Bands.Add "Values", "Values"
.Columns.Add("Name", "Item").Width = 2600
With .Columns.Add("Price", "Price", "Values")
.Format = "Currency": .Summary = wsuSum
End With
.ShowFooter = True
End With
Debug.Print Me!List1.Object.CellText(7, "Price"), Me!List1.Object.SummaryValue("Price")
Inheritance
WklTreeList inherits every member of `WklTreeView`; inherited members are described on the base class's page.
Columns property
Signature
Property Get Columns() As WklColumns
Summary
Returns the columns.
Parameters
None
Property value: `WklColumns` – The `WklColumns` collection, for example Columns("Price").Width = 1200.
Remarks
Read-only.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
Bands property
Signature
Property Get Bands() As WklBands
Summary
Returns the bands of the header.
Parameters
None
Property value: `WklBands` – The `WklBands` collection.
Remarks
Read-only.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
FormatRules property
Signature
Property Get FormatRules() As WklFormatRules
Summary
Returns the conditional formatting rules.
Parameters
None
Property value: `WklFormatRules` – The `WklFormatRules` collection.
Remarks
Read-only.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
ColumnLayout property
Signature
Property Get ColumnLayout() As String Property Let ColumnLayout(RHS As String)
Summary
Gets or sets the columns, bands and format rules as text.
Parameters
None
Property value: String – The layout text that Access saves with the form.
Remarks
In the property sheet, [...] opens the column designer. Copy the text to transfer a layout from one list to another.
Read/write.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
TreeColumn property
Signature
Property Get TreeColumn() As String Property Let TreeColumn(RHS As String)
Summary
Gets or sets the column that holds the tree (indentation and expand buttons).
Parameters
None
Property value: String – A column name; empty for the first visible column.
Remarks
Read/write.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
ShowHeader property
Signature
Property Get ShowHeader() As Boolean Property Let ShowHeader(RHS As Boolean)
Summary
Gets or sets whether the column headers are shown.
Parameters
None
Property value: Boolean – True (default) to show them.
Remarks
Read/write.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
GridLines property
Signature
Property Get GridLines() As WklGridLines Property Let GridLines(RHS As WklGridLines)
Summary
Gets or sets the grid lines.
Parameters
None
Property value: `WklGridLines` – A `WklGridLines` constant. Default: wglBoth.
Remarks
Read/write.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
ShowFooter property
Signature
Property Get ShowFooter() As Boolean Property Let ShowFooter(RHS As Boolean)
Summary
Gets or sets whether the footer with the column totals is shown.
Parameters
None
Property value: Boolean – True to show it; False (default) to hide it.
Remarks
Read/write.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
RowHeight property
Signature
Property Get RowHeight() As Long Property Let RowHeight(RHS As Long)
Summary
Gets or sets the height of a record row in twips.
Parameters
None
Property value: Long – The height; 0 (default) to derive it from the font.
Remarks
Read/write.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
AlternateBackColor property
Signature
Property Get AlternateBackColor() As Long Property Let AlternateBackColor(RHS As Long)
Summary
Gets or sets the background color of every second row.
Parameters
None
Property value: Long – A color number; -1 (default) for the same color as BackColor.
Remarks
Read/write.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
AllowEditing property
Signature
Property Get AllowEditing() As Boolean Property Let AllowEditing(RHS As Boolean)
Summary
Gets or sets whether cells can be edited.
Parameters
None
Property value: Boolean – True (default) to allow editing with F2, Enter, typing or a double-click.
Remarks
WklColumn.ReadOnly protects single columns. Group nodes (GroupFields) are never editable.
Read/write.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
FocusedColumn property
Signature
Property Get FocusedColumn() As String Property Let FocusedColumn(RHS As String)
Summary
Gets or sets the column of the focused cell.
Parameters
None
Property value: String – The column name.
Remarks
Read/write.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
CellValue property
Signature
Property Get CellValue(ByVal Key As Variant, ByVal Column As String) As Variant Property Let CellValue(ByVal Key As Variant, ByVal Column As String, RHS As Variant)
Summary
Gets or sets the value of a cell.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Key | Variant | No | – | The key of the node. |
Column | String | No | – | The column name. |
Property value: Variant – The stored value of the field.
Remarks
Setting the value saves it; with AutoSave it is written into the record source. A group node (GroupFields) has no field values; reading them returns Null.
Read/write.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
CellText property
Signature
Property Get CellText(ByVal Key As Variant, ByVal Column As String) As String
Summary
Returns the displayed text of a cell.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Key | Variant | No | – | The key of the node. |
Column | String | No | – | The column name. |
Property value: String – The text with the column's format applied; for a lookup column the displayed list value.
Remarks
Read-only.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
SummaryValue property
Signature
Property Get SummaryValue(ByVal Column As String) As Variant
Summary
Returns the total of a column.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Column | String | No | – | The column name. |
Property value: Variant – The value of the column's Summary over the loaded records; Null without a summary.
Remarks
Read-only.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
BestFitColumns method
Signature
Sub BestFitColumns()
Summary
Sets the width of every visible column to fit its header and contents.
Parameters
None
Remarks
Measures the header and the text of every loaded record in each visible column as the list shows it (format, lookup text, label of a status column) and adds the indent of the record's level in the tree column. At most the first 5,000 records in display order (a parent before its children) are measured. The widths are saved with the form like widths the user drags.
Loaded records: without LazyLoad, all records, also those below collapsed nodes. With `LazyLoad`, only the levels read so far, that is the levels down to `ExpandLevel` and the children of nodes that were expanded before; children read later, when their node is expanded, are not measured. Call BestFitColumns again after `ExpandAll` or after expanding nodes. Records not read yet (before the first load) leave only the headers to measure.
Call it while the control is shown in form view (for example in Form_Current or after Requery), not in Form_Open: without its window the control measures the texts without the tree indent and without the room for symbols and labels, so records of deeper levels stay shortened. There is no separate fitting for child records; the measurement above already includes every loaded level.
An error of the method itself raises a run-time error in VBA. Records the control reads on its own, such as the children of a node expanded with LazyLoad, report a failure through `DataError` instead; unless the event procedure sets Response to 0 (acDataErrContinue), the control shows the message in a box with its name as title („WKL TreeList“).
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
EditCell method
Signature
Sub EditCell(ByVal Key As Variant, ByVal Column As String)
Summary
Opens the editor of a cell in form view.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Key | Variant | No | – | The key of the node. |
Column | String | No | – | The column name. |
Remarks
A group node (GroupFields) raises wkeInvalidValue.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
GroupFields property
Signature
Property Get GroupFields() As String Property Let GroupFields(RHS As String)
Summary
Gets or sets the fields by which flat records are grouped into a tree.
Parameters
None
Property value: String – Field names separated by semicolons, outermost first; empty for no grouping.
Remarks
Every distinct value becomes a group node with the value as text ((leer) for an empty value) and the number of records as tooltip; the records are the leaves. With grouping, ParentField may be empty; when it is set, a record stays below its parent record.
Group nodes stand for no record: they cannot be edited or deleted, adding and moving are switched off, and totals count only records. Grouped records are always loaded completely.
The groups of a level are ordered by their group value, compared by its type (numbers and dates as numbers and dates, not as text), in the direction of SortOrder: wsoAscending (default) puts the oldest day first, wsoDescending the newest. SortOrder applies to every group level. A column sort (SortDirection) orders the records below a group; group nodes have no value in any column except the column of TextField, so a sort on another column leaves the order of the groups to SortOrder. A hidden column of a group field therefore does not order the groups. From release 1.62, a sort on the column of TextField orders the groups by their value in the column's direction; before, it compared the displayed text, so dates and numbers could stand out of order.
Read/write.
Code example
With Me!List1.Object
.RecordSource = "ptqTasksFlat"
.KeyField = "TaskID": .ParentField = "": .TextField = "Instruction"
.GroupFields = "Site;Building;Floor"
End With
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
ExportToXlsx method
Signature
Sub ExportToXlsx(ByVal Path As String, Optional ByVal Mode As WklExportMode = wemDataAware, Optional ByVal Rows As WklExportRows = werAll, Optional ByVal RawValues As Boolean = False, Optional ByVal AutoStart As Boolean = False)
Summary
Exports the list as an Excel workbook, without Excel.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Path | String | No | – | The file path; a relative path is resolved against the folder of the database. |
Mode | `WklExportMode` | Yes | wemDataAware | The kind of export; default wemDataAware. |
Rows | `WklExportRows` | Yes | werAll | Which records to export; default werAll. |
RawValues | Boolean | Yes | False | True to export the stored values of lookup columns instead of their displayed text. |
AutoStart | Boolean | Yes | False | True to open the file afterwards. |
Remarks
The visible columns are exported in display order with their values and types; numbers and dates keep the column's format. The tree becomes an Excel outline with the summary rows on top, and collapsed nodes are collapsed in Excel. Footer totals are written as SUBTOTAL formulas with their value. The header row is frozen and repeated on every printed page. With LazyLoad, werAll reads all records once. A missing folder raises wkeInvalidValue. With wemWysiwyg the workbook shows the list as displayed: bands and multi-line records as merged cells, the colors and fonts of the format rules, grid lines, the tree indented; values keep their type, footer totals are values instead of formulas. Data bars and icon sets are not exported.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
ExportToFile method
Signature
Sub ExportToFile(ByVal Path As String, Optional ByVal Format As WklExportFormat = wefAuto, Optional ByVal Mode As WklExportMode = wemDataAware, Optional ByVal Rows As WklExportRows = werAll, Optional ByVal RawValues As Boolean = False, Optional ByVal AutoStart As Boolean = False)
Summary
Exports the list in a file format.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Path | String | No | – | The file path; a relative path is resolved against the folder of the database. |
Format | `WklExportFormat` | Yes | wefAuto | The file format; wefAuto (default) chooses it from the file extension. |
Mode | `WklExportMode` | Yes | wemDataAware | The kind of export; default wemDataAware. |
Rows | `WklExportRows` | Yes | werAll | Which records to export; default werAll. |
RawValues | Boolean | Yes | False | True to export the stored values of lookup columns instead of their displayed text. |
AutoStart | Boolean | Yes | False | True to open the file afterwards. |
Remarks
wefAuto takes the format from the extension: .xlsx (also without extension), .xml or .json; another extension raises wkeInvalidValue. A path without extension gets the one of the format. Mode applies to the workbook only: XML and JSON always hold the data of the list. The rules of ExportToXlsx apply to the XLSX format, those of ExportToXml and ExportToJson to the others.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
ExportToXml method
Signature
Sub ExportToXml(ByVal Path As String, Optional ByVal Rows As WklExportRows = werAll, Optional ByVal RawValues As Boolean = False, Optional ByVal AutoStart As Boolean = False)
Summary
Exports the list as XML, without Excel: the columns, the records as a tree with their values, and the sums.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Path | String | No | – | The file path; a relative path is resolved against the folder of the database. |
Rows | `WklExportRows` | Yes | werAll | Which records to export; default werAll. |
RawValues | Boolean | Yes | False | True to export the stored values of lookup columns instead of their displayed text. |
AutoStart | Boolean | Yes | False | True to open the file afterwards. |
Remarks
The root element list (attributes format="WklTreeListExport", version, name of the control) holds columns (field, caption, format, summary), rows and summaries. Each row carries key, keyType and text, expanded when it has children, and group="true" for a group of GroupFields; its value elements hold one value per column with the field name and the VBA type name in type (Long, Decimal for currency, Double, Date as ISO 8601, Boolean as true/false), and the rows of its children follow inside it. A missing value is an empty element without type. Unlike SaveToFile, the file holds the data as shown - the visible columns, lookup columns with their displayed text - and cannot be loaded by the list.
Code example
Me!List1.Object.ExportToXml "Orders.xml"
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
ExportToJson method
Signature
Sub ExportToJson(ByVal Path As String, Optional ByVal Rows As WklExportRows = werAll, Optional ByVal RawValues As Boolean = False, Optional ByVal AutoStart As Boolean = False)
Summary
Exports the list as JSON, without Excel: the columns, the records as a tree with their values, and the sums.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Path | String | No | – | The file path; a relative path is resolved against the folder of the database. |
Rows | `WklExportRows` | Yes | werAll | Which records to export; default werAll. |
RawValues | Boolean | Yes | False | True to export the stored values of lookup columns instead of their displayed text. |
AutoStart | Boolean | Yes | False | True to open the file afterwards. |
Remarks
The object has format ("WklTreeListExport"), version, name, columns, rows and summaries. Each row has key (an array for a composite key), text, expanded when it has children, group for a group of GroupFields, values with one entry per column, and children. Numbers are JSON numbers, Yes/No true/false, dates ISO 8601 text ("2026-09-02", with time "2026-09-02T10:30:00"), missing values null. WKL Office JSON reads the file directly (JDoc.Load, SelectNodes("$..values")).
Code example
Me!List1.Object.ExportToJson "Orders.json", Rows:=werVisible
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
AllowExport property
Signature
Property Get AllowExport() As Boolean Property Let AllowExport(RHS As Boolean)
Summary
Gets or sets whether the shortcut menu offers Export ….
Parameters
None
Property value: Boolean – True (default) to offer the export; False to hide the item.
Remarks
The user chooses the file and the format (Excel workbook, XML, JSON) in the save dialog; ExportMode and ExportRows decide the rest. An Excel workbook opens afterwards. The methods ExportToXlsx, ExportToXml, ExportToJson and ExportToFile work regardless of this setting. The value is saved with the form.
Read/write.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
ExportMode property
Signature
Property Get ExportMode() As WklExportMode Property Let ExportMode(RHS As WklExportMode)
Summary
Gets or sets how the context menu's export writes an Excel workbook.
Parameters
None
Property value: `WklExportMode` – wemDataAware (default) or wemWysiwyg.
Remarks
Applies to the Excel workbook only; XML and JSON always hold the data of the list. Invalid values raise wkeInvalidValue. The value is saved with the form.
Read/write.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
ExportRows property
Signature
Property Get ExportRows() As WklExportRows Property Let ExportRows(RHS As WklExportRows)
Summary
Gets or sets which records the context menu's export writes.
Parameters
None
Property value: `WklExportRows` – werAll (default) or werVisible.
Remarks
werAll includes the records below collapsed nodes (with LazyLoad they are read once), werVisible only what the list shows. Invalid values raise wkeInvalidValue. The value is saved with the form.
Read/write.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
NewRecord method
Signature
Sub NewRecord()
Summary
Starts a new record as the user does with Ctrl++ or the shortcut menu.
Parameters
None
Remarks
In a WklGrid the focus goes to the row for a new record and its first editable cell opens; the record is added when the user leaves the row (BeforeInsert, AfterInsert). In a WklTreeList a new node is added after the focused one, as Ins does (BeforeNodeAdd, AfterNodeAdd). With an edit form (EditForm, EditFormMode) the form opens in add mode instead, after the call has returned. Raises wkeNotAvailable when CanAdd is False or the control is not in form view.
Called in an event procedure of the same control (for example ItemCommand, RowCommand, ItemClick, RowClick), the command runs right after that procedure has ended, not during the call: VBA does not deliver an event of an object while an event procedure of the same object runs, so BeforeDelete, BeforeInsert or BeforeEditForm would otherwise not reach the form. The method returns before the command has run. Code after it in the same procedure still sees the old state - the record is still there, RecordCount is unchanged - and cannot tell whether the user or Cancel refused. The result shows in the events that follow: AfterDelete after a deletion, AfterInsert after a new record, AfterEditForm after the edit form. Code that reacts to the result - for example a WklToast note with Undo after a deletion - belongs there. Availability is checked at once: an unavailable command still raises wkeNotAvailable in the call.
Code example
Private Sub cmdNew_Click()
Me!Grid1.SetFocus
Me!Grid1.Object.NewRecord
End Sub
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
DeleteSelected method
Signature
Sub DeleteSelected()
Summary
Deletes the selected records as the Delete key does.
Parameters
None
Remarks
BeforeDelete occurs for each record, with its question unless the procedure sets Confirm to False; AfterDelete follows each deletion. With MultiSelect all selected records are deleted. Raises wkeNotAvailable when CanDelete is False (no AllowDeletions, nothing focused, a group row or the row for a new record) or the control is not in form view.
Called in an event procedure of the same control (for example ItemCommand, RowCommand, ItemClick, RowClick), the command runs right after that procedure has ended, not during the call: VBA does not deliver an event of an object while an event procedure of the same object runs, so BeforeDelete, BeforeInsert or BeforeEditForm would otherwise not reach the form. The method returns before the command has run. Code after it in the same procedure still sees the old state - the record is still there, RecordCount is unchanged - and cannot tell whether the user or Cancel refused. The result shows in the events that follow: AfterDelete after a deletion, AfterInsert after a new record, AfterEditForm after the edit form. Code that reacts to the result - for example a WklToast note with Undo after a deletion - belongs there. Availability is checked at once: an unavailable command still raises wkeNotAvailable in the call.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
EditSelected method
Signature
Sub EditSelected()
Summary
Opens the editor of the focused cell, or of the first editable cell of the focused record; with an edit form, opens the form for the focused record.
Parameters
None
Remarks
BeforeCellEdit occurs first and can cancel; a cancel is no error. With EditForm and an EditFormMode other than wfmNone the edit form opens instead, after the call has returned (BeforeEditForm). Raises wkeNotAvailable when CanEdit is False or the control is not in form view. Call SetFocus on the control first, so that the user can type into the editor.
Called in an event procedure of the same control (for example ItemCommand, RowCommand, ItemClick, RowClick), the command runs right after that procedure has ended, not during the call: VBA does not deliver an event of an object while an event procedure of the same object runs, so BeforeDelete, BeforeInsert or BeforeEditForm would otherwise not reach the form. The method returns before the command has run. Code after it in the same procedure still sees the old state - the record is still there, RecordCount is unchanged - and cannot tell whether the user or Cancel refused. The result shows in the events that follow: AfterDelete after a deletion, AfterInsert after a new record, AfterEditForm after the edit form. Code that reacts to the result - for example a WklToast note with Undo after a deletion - belongs there. Availability is checked at once: an unavailable command still raises wkeNotAvailable in the call.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
CopySelected method
Signature
Sub CopySelected()
Summary
Copies the focused cell, or the selected records with a header row, to the clipboard as Ctrl+C does.
Parameters
None
Remarks
A single cell is copied as text; several records as tab-separated text and as an HTML table, as an Access datasheet copies them. Group rows and the row for a new record are not copied. Raises wkeNotAvailable when the control is not in form view.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
ShowExportDialog method
Signature
Sub ShowExportDialog()
Summary
Shows the export dialog of the shortcut menu: Excel workbook, XML or JSON file.
Parameters
None
Remarks
ExportMode and ExportRows apply as for the menu entry. Raises wkeNotAvailable when AllowExport is False or the control is not in form view. The methods ExportToXlsx, ExportToXml, ExportToJson and ExportToFile export without a dialog.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
ShowContextMenu method
Signature
Sub ShowContextMenu()
Summary
Opens the shortcut menu of the focused record below its focused cell, as the menu key does.
Parameters
None
Remarks
NodeRightClick (RowRightClick in a WklGrid) does not occur, as for the menu key. Raises wkeNotAvailable when no record is focused or the control is not in form view.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
CanAdd property
Signature
Property Get CanAdd() As Boolean
Summary
Gets whether NewRecord can start a new record now.
Parameters
None
Property value: Boolean – True when AllowAdditions is set and, in a WklGrid, the grid shows the row for a new record (NewItemRow, AllowEditing, a record source the grid writes to); in a WklTreeList, when the records' own hierarchy is shown (no GroupFields) and the master allows writing. With an edit form, when AllowAdditions is set, the master allows writing and a form for new records is set (EditForm, or the entry of EditForms without kind). False outside form view.
Remarks
The value is the enabled state of the shortcut menu's New record (New node here in a WklTreeList). Read-only. Reading it sets the starting point for CommandStateChange, as reading CanDelete, CanEdit and CanExport does.
Read-only.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
CanDelete property
Signature
Property Get CanDelete() As Boolean
Summary
Gets whether DeleteSelected can delete now.
Parameters
None
Property value: Boolean – True with AllowDeletions when a record is focused that is neither a group row nor the row for a new record. False outside form view.
Remarks
The value is the enabled state of the shortcut menu's Delete. Read-only.
Read-only.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
CanEdit property
Signature
Property Get CanEdit() As Boolean
Summary
Gets whether EditSelected can open a cell editor now.
Parameters
None
Property value: Boolean – True with AllowEditing when the focused record has a cell that can be edited: a column that is not read-only and not a check box, a status link or a command column. With an edit form, True when a form edits the focused record (EditForm, EditForms), whatever AllowEditing says. False outside form view.
Remarks
Read-only.
Read-only.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
CanExport property
Signature
Property Get CanExport() As Boolean
Summary
Gets whether ShowExportDialog can show the export dialog.
Parameters
None
Property value: Boolean – True with AllowExport in form view.
Remarks
Read-only.
Read-only.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
AutoSaveLayout property
Signature
Property Get AutoSaveLayout() As Boolean Property Let AutoSaveLayout(RHS As Boolean)
Summary
Gets or sets whether the user's arrangement of the columns is remembered per Windows user.
Parameters
None
Property value: Boolean – True (default) to remember and restore it; False to show the design every time.
Remarks
Remembered are column widths, order, hidden columns, bands, sorting, GroupFields, the column filters of a WklGrid and its DetailHeight - as the difference from the design, so a later change of the design still reaches every column the user did not touch; columns removed from the design are ignored, new ones appear as designed. Not remembered: selection, search text and expanded records or groups.
The design is what the control shows when form view first displays it: the columns saved with the form plus what Form_Load changed by code. The remembered arrangement is applied then, before the records are read; every later change - by the user or by code - is stored at once, and a change back to the design removes it. A Layout set by code before the control shows wins over the remembered arrangement.
In Access the arrangement goes into the local table USysWklLayout of the database holding the form (one row per Windows user and key, as for WklDockLayout); on Excel and Word UserForms into HKEY_CURRENT_USER\Software\The White Knight Labs\Access Framework\Layouts. A read-only front end does not break the form; the arrangement is then not remembered. The value is saved with the form.
Read/write.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
LayoutKey property
Signature
Property Get LayoutKey() As String Property Let LayoutKey(RHS As String)
Summary
Gets or sets the name the arrangement is remembered under.
Parameters
None
Property value: String – Up to 255 characters; empty (default) for „form name.control name“.
Remarks
Two lists with the same key share one arrangement. A form used as subform in several places shares its arrangement already, because the key names the form holding the control. Longer keys raise wkeInvalidValue. The value is saved with the form.
Read/write.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
Reset method
Signature
Sub Reset()
Summary
Shows the columns, sorting, grouping, filters and detail height of the design again and removes the user's remembered arrangement.
Parameters
None
Remarks
Before form view showed the control, nothing changes. Selection and expanded records stay.
Code example
Private Sub cmdDefaultColumns_Click()
Me!Grid1.Object.Reset ' also removes the user's row in USysWklLayout
End Sub
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
ShortcutMenuBar property
Signature
Property Get ShortcutMenuBar() As String Property Let ShortcutMenuBar(RHS As String)
Summary
Gets or sets the name of an Access shortcut menu bar whose entries the control's shortcut menu shows.
Parameters
None
Property value: String – The name of a popup command bar in Application.CommandBars, up to 255 characters; empty (default) for none.
Remarks
The property is the control's counterpart of the Shortcut Menu Bar (ShortcutMenuBar) of Access forms and controls, which Access does not offer for an ActiveX control. It gives the control a shortcut menu of the application without a form module: each entry runs its action (OnAction, an expression such as =MarkOrderDone() or the name of a macro) the way Office runs it from a command bar. The control has the focus during the call, so the function reaches it through Screen.ActiveControl and the record through ContextKey.
The menu shows the visible buttons and submenus of the bar with their caption (& marks the access key), ShortcutText, enabled state, the pressed state (State = msoButtonDown) as a check mark, and BeginGroup as a separator line. Combo boxes, edit boxes and pictures (FaceId, Picture) of a bar are not shown. The bar is read each time the menu opens, so a change by code - CommandBars("mnuOrders").Controls(1).Enabled = False - shows the next time. A name Access does not know adds no entries. An entry whose function does not exist shows the message of Access that the expression contains the name of a function it cannot find, as for an entry of an Access bar. An error the function does not handle shows the runtime error dialog of VBA, as for an entry of an Access bar - handle errors inside the function.
MenuPlacement sets where the entries stand next to the built-in ones. In a WklGrid, detail views show the same entries; ContextView names the view. The value is saved with the form; the bar is not part of the form. Create it in code when the application starts, as in the example: the bar is then the same in every copy of the front end, in ACCDE files and in the Access Runtime.
Read/write.
Code example
' Standard module basMenus. Run CreateOrderMenu once at start,
' for example from the AutoExec macro (RunCode CreateOrderMenu()).
Public Function CreateOrderMenu()
On Error Resume Next
CommandBars("mnuOrders").Delete
On Error GoTo 0
With CommandBars.Add("mnuOrders", 5, False, True) ' 5 = msoBarPopup, temporary
With .Controls.Add(1) ' 1 = msoControlButton
.Caption = "Als &erledigt markieren"
.OnAction = "=MarkOrderDone()"
End With
With .Controls.Add(1)
.Caption = "&Lieferschein drucken"
.OnAction = "=PrintDeliveryNote()"
.BeginGroup = True
End With
End With
End Function
Public Function MarkOrderDone()
Dim grid As Object
Set grid = Screen.ActiveControl.Object
If IsNull(grid.ContextKey) Then Exit Function
CurrentDb.Execute "UPDATE tblOrders SET Done = True WHERE OrderID = " & grid.ContextKey, dbFailOnError
grid.Requery
End Function
Public Function PrintDeliveryNote()
DoCmd.OpenReport "rptDeliveryNote", acViewPreview, , "OrderID = " & Screen.ActiveControl.Object.ContextKey
End Function
In design view, set ShortcutMenuBar of the grid to mnuOrders (property sheet, Other tab, or the designer page Behavior).
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
MenuPlacement property
Signature
Property Get MenuPlacement() As WklMenuPlacement Property Let MenuPlacement(RHS As WklMenuPlacement)
Summary
Gets or sets where the own entries stand in the shortcut menu.
Parameters
None
Property value: `WklMenuPlacement` – A WklMenuPlacement value; wmpOwnAfter (default) puts them after the built-in entries.
Remarks
Own entries are the entries of ShortcutMenuBar, followed by those added with AddMenuItem; a separator line divides them from the built-in entries. ContextMenu = False removes the built-in entries in every placement. Other values raise wkeInvalidValue. The value is saved with the form.
Read/write.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
ContextKey property
Signature
Property Get ContextKey() As Variant
Summary
Gets the key of the record the shortcut menu was last opened on.
Parameters
None
Property value: Variant – The key, in the type of the key field; Null when the menu was opened on a group row or has not been opened yet.
Remarks
The value is set before BeforeContextMenu and kept until the menu opens again, so the actions of the entries - functions of ShortcutMenuBar, MenuItemClick - work on the record the menu belongs to, also when the menu was opened with the menu key, Shift+F10 or ShowContextMenu. In a detail view of a WklGrid it is the key of the detail record, and it is the master grid's property that holds it (ContextView names the view). Read-only.
Read-only.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
ContextColumn property
Signature
Property Get ContextColumn() As String
Summary
Gets the column the shortcut menu was last opened on.
Parameters
None
Property value: String – The column name; empty when the menu was opened outside a cell.
Remarks
Read-only. Set together with ContextKey.
Read-only.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
ContextView property
Signature
Property Get ContextView() As String
Summary
Gets the detail view the shortcut menu was last opened in.
Parameters
None
Property value: String – The name of the detail view, as DetailGrid takes it; empty when the menu was opened in the control itself.
Remarks
Only a WklGrid has detail views; in a WklTreeList and a WklGantt the value is always empty. Read-only.
Read-only.
Code example
Public Function ShowContext()
With Screen.ActiveControl.Object
If .ContextView = "" Then
MsgBox "Auftrag " & .ContextKey
Else
MsgBox "Position " & .ContextKey & " in " & .ContextView
End If
End With
End Function
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
MenuItemEnabled property
Signature
Property Get MenuItemEnabled(ByVal Tag As String) As Boolean Property Let MenuItemEnabled(ByVal Tag As String, RHS As Boolean)
Summary
Gets or sets whether a custom menu item can be chosen.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Tag | String | No | – | The tag given to AddMenuItem. |
Property value: Boolean – True (default) or False; a disabled item is shown grayed.
Remarks
An unknown tag raises wkeInvalidValue. AddMenuItem with an existing tag replaces the item and resets this and the other MenuItem... properties. Set it in BeforeContextMenu to follow the record the menu opens on.
Read/write.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
MenuItemChecked property
Signature
Property Get MenuItemChecked(ByVal Tag As String) As Boolean Property Let MenuItemChecked(ByVal Tag As String, RHS As Boolean)
Summary
Gets or sets whether a custom menu item shows a check mark.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Tag | String | No | – | The tag given to AddMenuItem. |
Property value: Boolean – True or False (default). A checked item shows the check mark instead of its glyph.
Remarks
An unknown tag raises wkeInvalidValue.
Read/write.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
MenuItemGlyph property
Signature
Property Get MenuItemGlyph(ByVal Tag As String) As String Property Let MenuItemGlyph(ByVal Tag As String, RHS As String)
Summary
Gets or sets the glyph of a custom menu item.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Tag | String | No | – | The tag given to AddMenuItem. |
Property value: String – A glyph code as for WklButton.Glyph; empty (default) for none.
Remarks
An unknown tag raises wkeInvalidValue; an unknown glyph code shows no glyph.
Read/write.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
MenuItemShortcut property
Signature
Property Get MenuItemShortcut(ByVal Tag As String) As String Property Let MenuItemShortcut(ByVal Tag As String, RHS As String)
Summary
Gets or sets the key combination shown at a custom menu item.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Tag | String | No | – | The tag given to AddMenuItem. |
Property value: String – The text shown at the right edge, for example Ctrl+P; empty (default) for none.
Remarks
Display only: the control does not bind the keys. An unknown tag raises wkeInvalidValue.
Read/write.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
MenuItemParent property
Signature
Property Get MenuItemParent(ByVal Tag As String) As String Property Let MenuItemParent(ByVal Tag As String, RHS As String)
Summary
Gets or sets the custom menu item whose submenu holds an item.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Tag | String | No | – | The tag given to AddMenuItem. |
Property value: String – The tag of the parent item; empty (default) for the menu itself.
Remarks
An item with child items opens its submenu and raises no MenuItemClick itself. A parent tag that names no item, or a chain of parents that leads back to the item, puts the item into the menu itself, so a slip in code never hides an item. An unknown Tag raises wkeInvalidValue.
Read/write.
Code example
Private Sub Form_Load()
With Me!Grid1.Object
.AddMenuItem "&Status", "status"
.AddMenuItem "Offen", "status.open"
.AddMenuItem "Erledigt", "status.done"
.MenuItemParent("status.open") = "status"
.MenuItemParent("status.done") = "status"
.AddMenuItem "&Drucken", "print", True
.MenuItemShortcut("print") = "Ctrl+P"
End With
End Sub
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
EditForm property
Signature
Property Get EditForm() As String Property Let EditForm(RHS As String)
Summary
Gets or sets the name of the Access form that edits a record of the list (the edit form).
Parameters
None
Property value: String – The name of a form of the database, up to 255 characters; empty (default) for editing in the cells.
Remarks
The edit form is an ordinary bound Access form, designed in Access without code; its record source is the table or query of the records it edits. The control draws no fields of its own: it opens the form, limits it to the chosen record and reads its records again when the form is done. Validation rules, required fields and errors of the data source are shown by the form, as in every Access form.
The form is used only while EditFormMode is not wfmNone. Then the commands that edit a record open the form instead of a cell editor:
| Input | Opens |
|---|---|
Double click on a record, Enter, F2, EditSelected | The form, filtered on the focused record |
Ctrl++, NewRecord, the shortcut menu entry New record | The form in add mode (acFormAdd) |
Group rows are no records and open nothing. CanEdit is True on a record that has a form, CanAdd when AllowAdditions is True and a form for new records is set. The form opens after the input has been handled, so the event procedures of the double click (NodeDblClick, RowDblClick, CellDblClick) run first.
The form is limited to the record with a WhereCondition over its key fields: [ID] = 17, or one comparison per field of a composite key joined with And. The fields are those of EditKeyFields, or the list's KeyField when it is empty. A record whose key has a Null part cannot be opened.
New record of a linked list (LinkChildFields with a master record): the controls of the form bound to the link fields get the master values as DefaultValue, as Access fills the link fields of a new record in a subform. The form needs a control for each link field; it may be invisible.
After a dialog is closed the list reads its records again (as Shift+F9) and keeps the selection; AfterEditForm follows. BeforeEditForm can choose another form or cancel.
The value is saved with the form. Outside an Access form (UserForm in Excel or Word) no form is opened.
Read/write.
Code example
' In design view: EditForm = frmCustomer, EditFormMode = wfmDialog.
' The same by code, for example in Form_Load:
Private Sub Form_Load()
With Me!Grid1.Object
.EditForm = "frmCustomer"
.EditFormMode = wfmDialog
End With
End Sub
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
EditKeyFields property
Signature
Property Get EditKeyFields() As String Property Let EditKeyFields(RHS As String)
Summary
Gets or sets the fields of the edit form's record source that hold the parts of the list's key.
Parameters
None
Property value: String – Field names separated by semicolons, in the order of KeyField; empty (default) when the form names them as the list does.
Remarks
Needed only when the names differ, typically in a tree over a UNION query whose common key column comes from a differently named field in each table. The number of fields must match the number of parts of KeyField; otherwise opening the form reports wkeInvalidValue through DataError. Applies to EditForm; a rule in EditForms names its own fields.
Read/write.
Code example
' The list reads tblOrderLine as Key = OrderNo;LineNo, the form names them OrderID;Position. Me!Grid1.Object.EditKeyFields = "OrderID;Position"
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
EditFormMode property
Signature
Property Get EditFormMode() As WklEditFormMode Property Let EditFormMode(RHS As WklEditFormMode)
Summary
Gets or sets where the edit form is shown.
Parameters
None
Property value: `WklEditFormMode` – A WklEditFormMode value; wfmNone (default) for editing in the cells.
Remarks
wfmDialog opens the form with acDialog: the user works in it, the list waits and reads again when it is closed. wfmWindow opens an ordinary form window (a tab or an overlapping window, as the database option Document Window Options sets); the list goes on at once and reads again when the window is closed. wfmDocked shows the form in the subform control EditFormControl of the list's own form, for example in a pane of a WklDockLayout, and follows the selection. wfmAuto docks while the list keeps enough width beside the subform control and opens a dialog otherwise. wfmOverlay uses the same subform control, but places it over the right part of the list (EditFormWidth) only while a record is edited, and hides it when the focus comes back to the list; it does not follow the selection.
The value is saved with the form.
Read/write.
Code example
Me!Grid1.Object.EditFormMode = wfmWindow
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
EditKindField property
Signature
Property Get EditKindField() As String Property Let EditKindField(RHS As String)
Summary
Gets or sets the field of the record source that holds the kind of a record, for the edit forms per kind in EditForms.
Parameters
None
Property value: String – A field name; empty (default) when every record has the same kind.
Remarks
A tree that shows several tables through a UNION query typically has a column such as Kind with values like Customer or Order. The list compares the value of that field with the kinds of EditForms: text without regard to case, numbers by value. The field may be any field of the record source: the list reads it with every record without showing it. Changing the property reads the records again.
Read/write.
Code example
With Me!Tree1.Object
.EditKindField = "Kind"
.EditForms = "{""forms"":[{""kind"":""Customer"",""form"":""frmCustomer"",""keys"":""CustomerID""}," & _
"{""kind"":""Order"",""form"":""frmOrder"",""keys"":""OrderID""}]}"
.EditFormMode = wfmDialog
End With
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
EditForms property
Signature
Property Get EditForms() As String Property Let EditForms(RHS As String)
Summary
Gets or sets the edit forms per kind of record, as JSON text.
Parameters
None
Property value: String – {"format":"WklEditForms","version":1,"forms":[...]} with one object per kind: kind (the value of EditKindField; left out for the form of every other record), form (the form name), keys (its key fields, as EditKeyFields; left out when named as in the list or in sourceKeys), sourceKeys (fields of the list's record source whose values make up the form's key, in the order of keys; left out when the list's key is the form's key), deleteFrom (the table or query the records of this kind are deleted from; left out for the form's record source) and children (the kinds that can be added below a record of this kind: objects with kind, optionally form, and link as FormField=ParentField pairs separated by semicolons). Empty (default) for none.
Remarks
Which form opens: the entry whose kind equals the record's kind, else the entry without kind, else EditForm.
A tree over a UNION query. Its KeyField must be unique across all tables, for example 'r5' for rule 5 and 'i5:resource' for an item of it, while each form needs the key of its table. sourceKeys names the columns of the union that carry that key ("sourceKeys":"RuleId;Item"); they need not be shown. Deleting a record of such a kind (DeleteSelected, Ctrl+-, the Delete key) deletes it in deleteFrom - or the form's RecordSource - over keys, with BeforeDelete, the question and AfterDelete as usual; a node with children deletes them first, each by the entry of its own kind. In a list with edit forms only records whose kind has a form can be deleted (CanDelete).
New records. NewRecord and Ctrl++ open the first kind of children of the focused record's entry, below that record: the controls bound to the link fields get the parent's values as default value, and the parent is expanded. Without such a kind - nothing focused, or a kind without children - they open the entry without kind, else EditForm, on the top level. NewRecordOfKind opens a given kind: below the focused record when its entry lists it, else on the top level. A child entry without form takes the form of the entry of its kind.
Setting an invalid text raises wkeInvalidValue with what is wrong: no valid JSON, an entry without form, a kind that occurs twice, keys and sourceKeys of different length, a child without kind, a malformed link, or a child whose kind has no form. Unknown properties are ignored, so a form saved by a newer version still opens. The value is saved with the form.
Read/write.
Code example
Debug.Print Me!Tree1.Object.EditForms
' {"format":"WklEditForms","version":1,"forms":[{"kind":"Customer","form":"frmCustomer","keys":"CustomerID"}]}
' A tree of rules and their items over a UNION query with the columns Key, Kind, Nr and Item:
With Me!Tree1.Object
.KeyField = "Key"
.EditKindField = "Kind"
.EditForms = "{""forms"":[" & _
"{""kind"":""Rule"",""form"":""frmRule"",""sourceKeys"":""Nr"",""keys"":""Id""," & _
"""children"":[{""kind"":""Item"",""link"":""RuleId=Nr""}]}," & _
"{""kind"":""Item"",""form"":""frmRuleItem"",""sourceKeys"":""Nr;Item"",""keys"":""RuleId;Item""," & _
"""deleteFrom"":""tblRuleItem""}]}"
.EditFormControl = "sfEdit"
.EditFormMode = wfmDocked
End With
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
EditFormControl property
Signature
Property Get EditFormControl() As String Property Let EditFormControl(RHS As String)
Summary
Gets or sets the subform control of the list's own form that shows the edit form when EditFormMode is wfmDocked, wfmAuto or wfmOverlay.
Parameters
None
Property value: String – The name of a subform control (ControlType acSubform) of the same form; empty (default) for none.
Remarks
The list sets the control's SourceObject to the edit form and filters it on the selected record whenever the selection changes. Access saves the record of the subform when the focus goes back to the list, as for any subform; the list then reads that record again. Without a usable control the docked and the automatic mode open a dialog, and so does the overlay without a control of that name. For wfmOverlay the control must come after the list in the form's order (Bring to Front) to lie above it; the list moves and sizes it over its own right part, makes it visible and hides it again afterwards. The value is saved with the form.
Read/write.
Code example
With Me!Grid1.Object
.EditForm = "frmCustomer"
.EditFormControl = "sfEdit"
.EditFormMode = wfmDocked
End With
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
EditFormResult property
Signature
Property Get EditFormResult() As WklEditFormResult
Summary
Gets what became of the record of the edit form that was done last.
Parameters
None
Property value: `WklEditFormResult` – A WklEditFormResult value; wfrUnchanged before any edit form.
Remarks
The list reads the record from its record source before the form opens and again after it is done, and compares all fields (text with regard to case): a form that saved without a change reports wfrUnchanged. For a new record it compares the keys the list holds before and after, without a query of its own; in server mode, where the list holds only part of its records, it compares the largest key (a single numeric key field). A new record the list does not show (outside its filter) is therefore reported as wfrUnchanged unless the list is in server mode. Without a record source the list can read again (a Recordset, a file) the result is wfrUnknown. A UNION query compares the columns of the union, not every field of the form's table. The value is set before AfterEditForm and stays until the next edit form is done; a detail view's result is read from the master grid.
Read-only.
Code example
Private Sub Grid1_AfterEditForm(ByVal Key As Variant, ByVal NewRecord As Boolean)
Select Case Me!Grid1.Object.EditFormResult
Case wfrAdded: Me!lblStatus.Caption = "Neu: " & Nz(Me!Grid1.Object.EditFormNewKey, "?")
Case wfrDeleted: Me!lblStatus.Caption = "Deleted"
End Select
End Sub
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
EditFormNewKey property
Signature
Property Get EditFormNewKey() As Variant
Summary
Gets the key of the record the edit form that was done last has added.
Parameters
None
Property value: Variant – The key in the list (as SelectedKey); Null when no record was added, or when several were added at the same time and the form's is not certain.
Remarks
The list selects that record, expands its parents and scrolls it into view. A record the list does not show (another master record, a filter) keeps its key here, but nothing is selected.
Read-only.
Code example
If Not IsNull(Me!Tree1.Object.EditFormNewKey) Then Debug.Print Me!Tree1.Object.NodeText(Me!Tree1.Object.EditFormNewKey)
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
EditFormWidth property
Signature
Property Get EditFormWidth() As Long Property Let EditFormWidth(RHS As Long)
Summary
Gets or sets the width of the overlaying edit form (wfmOverlay).
Parameters
None
Property value: Long – A width in twips; 0 (default) for the width of the subform control EditFormControl from design view.
Remarks
The overlay never gets wider than the list. A negative value raises wkeInvalidValue. The value is saved with the form.
Read/write.
Code example
Me!Grid1.Object.EditFormWidth = 6 * 567 ' 6 cm
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
NewRecordOfKind method
Signature
Sub NewRecordOfKind(ByVal Kind As String)
Summary
Starts a new record of a kind in its edit form.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Kind | String | No | – | A kind of EditForms. |
Remarks
Below the focused record when the entry of its kind lists Kind in children (with the link values of the focused record as default values), else on the top level with the entry of Kind. Raises wkeNotAvailable when CanAddKind(Kind) is False. For one button per kind, as „Neue Regel“ and „Neues Merkmal“.
Code example
Private Sub cmdNewItem_Click()
If Me!Tree1.Object.CanAddKind("Item") Then Me!Tree1.Object.NewRecordOfKind "Item"
End Sub
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
CanAddKind property
Signature
Property Get CanAddKind(ByVal Kind As String) As Boolean
Summary
Gets whether NewRecordOfKind can start a record of a kind now.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Kind | String | No | – | A kind of EditForms. |
Property value: Boolean – True when AllowAdditions is set, the list edits in forms and a form takes this kind below the focused record or on the top level.
Remarks
Read it in CommandStateChange and after a change of the selection to enable your own buttons.
Read-only.
Code example
Me!cmdNewItem.Enabled = Me!Tree1.Object.CanAddKind("Item")
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
ValidateMode property
Signature
Property Get ValidateMode() As WklValidateMode Property Let ValidateMode(RHS As WklValidateMode)
Summary
Gets or sets when the rules of the columns are checked.
Parameters
None
Property value: `WklValidateMode` – A WklValidateMode value; wvmOnLeave (default).
Remarks
A value that breaks a rule is never written, as Access does not save a value that breaks a field's validation rule: the cell editor stays open, the cell shows a red frame with the error symbol and the message as tooltip, and the error bar below the records counts the errors; there is no message box. Escape discards the input. wvmOnLeave checks when the editor is left (Enter, Tab, a click elsewhere), wvmImmediate marks the input while the user types and refuses it when the editor is left, wvmOnSave checks the row for a new record only when it is saved. Existing records are saved cell by cell, so their cells are checked when they are left in every mode. The value is saved with the form.
Read/write.
Code example
Me!Grid1.Object.ValidateMode = wvmImmediate
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
SetError method
Signature
Sub SetError(ByVal Key As Variant, ByVal Column As String, ByVal Text As String)
Summary
Shows an error at a cell or at a record.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Key | Variant | No | – | The record's key; Null for the row for a new record. |
Column | String | No | – | The name or field of a column; empty for an error of the record as a whole. |
Text | String | No | – | The message; empty to remove the error. |
Remarks
For rules the columns cannot express - over several fields, or the refusal of a data service that names no field: the cell shows a red frame, the record without column a red bar at its left edge; the message is the tooltip and the text of the error bar. A write the data source refused is kept with the source's text by the list itself. An error of the application stays until it is removed with an empty Text or ClearErrors. An unknown column raises wkeKeyNotFound.
Code example
Private Sub Grid1_ValidateCell(ByVal Key As Variant, ByVal Column As String, NewValue As Variant, Cancel As Integer)
If Column = "Login" And IsNull(NewValue) And Me!Grid1.Object.CellValue(Key, "Kind") = "Login" Then
Cancel = True
Me!Grid1.Object.SetError Key, "Login", "A sign-in needs a login name."
End If
End Sub
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
ClearErrors method
Signature
Sub ClearErrors(Optional ByVal Key As Variant)
Summary
Removes the errors of a record, or every error.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Key | Variant | Yes | – | The record's key; left out for every error. |
Remarks
Removes the errors of the rules as well as those of SetError; a rule that is still broken is reported again when its cell is checked next.
Code example
Me!Grid1.Object.ClearErrors
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
ErrorCount property
Signature
Property Get ErrorCount() As Long
Summary
Gets the number of errors shown.
Parameters
None
Property value: Long – The errors of all cells and records; 0 without errors.
Remarks
Read it in ValidationChange to enable your own buttons, for example a Save button that only makes sense without errors.
Read-only.
Code example
Me!cmdWeiter.Enabled = (Me!Grid1.Object.ErrorCount = 0)
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
ErrorText property
Signature
Property Get ErrorText(ByVal Key As Variant, ByVal Column As String) As String
Summary
Gets the message of a cell or of a record.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Key | Variant | No | – | The record's key; Null for the row for a new record. |
Column | String | No | – | The name or field of a column; empty for the record. |
Property value: String – The message; empty when the cell or record has no error.
Remarks
An unknown column raises wkeKeyNotFound.
Read-only.
Code example
Debug.Print Me!Grid1.Object.ErrorText(Me!Grid1.Object.SelectedKey, "Netz")
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
GoToFirstError method
Signature
Sub GoToFirstError()
Summary
Selects the record of the first error and shows its cell.
Parameters
None
Remarks
The first error is the one found first. The list expands the record's parents and scrolls to it, as the button Go to the first error of the error bar does. Raises wkeNotAvailable without errors and outside form view.
Code example
If Me!Grid1.Object.ErrorCount > 0 Then Me!Grid1.Object.GoToFirstError
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
ErrorSummary property
Signature
Property Get ErrorSummary() As String
Summary
Gets the summary of the errors as the error bar shows it.
Parameters
None
Property value: String – „1 Fehler“, „2 Fehler“ …; empty without errors.
Remarks
Read-only.
Code example
Me!lblFehler.Caption = Me!Grid1.Object.ErrorSummary
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
EditOnClick property
Signature
Property Get EditOnClick() As Boolean Property Let EditOnClick(RHS As Boolean)
Summary
Gets or sets whether a single click into an editable cell opens its editor.
Parameters
None
Property value: Boolean – True or False; default False (a click selects a node, as in Explorer; WklGantt inherits the property and the default).
Remarks
With True a click into a cell edits it as in an Access datasheet: the editor opens and the caret lands where the click was (after the last character when the click was right of the text). A drop-down list does not open on the click; its arrow or Alt+Down opens it. A double click selects the word under the caret and raises DblClick and CellDblClick as without the setting. With False a click only selects the record; F2, Enter, typing or a double click open the editor. The click edits only where editing is possible at all: AllowEditing is True, the column is not read-only and the source can be written. A check box, a toggle switch, a command button, a status link and an edit form (EditForm) keep their own click. Ctrl+click and Shift+click still extend the selection. The value is saved with the form; a form saved before version 1.47 takes the default.
Read/write.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
ShowFilterRow property
Signature
Property Get ShowFilterRow() As Boolean Property Let ShowFilterRow(RHS As Boolean)
Summary
Gets or sets whether the filter row is shown below the column headers.
Parameters
None
Property value: Boolean – True to show the row; False (default) to hide it.
Remarks
Each cell of the filter row takes one condition for its column, applied while the user types. A leading operator (=, <>, <, <=, >, >=) works for every column; text without an operator means „begins with“, or LIKE when it contains * or ?; a number or date without an operator means „equals“. leer selects blank values; „not empty“ in the language of the components (not empty, nicht leer, ni prazno …) selects the others. Numbers and dates are read in the Windows regional format first and invariantly second; thousands separators are not accepted. Input that does not fit the column, such as letters in a number column, is shown in red and leaves the filter unchanged. Esc clears the cell.
A node that meets every condition stays visible together with its parent nodes, which open so that the node can be seen in its place; other nodes are hidden. With FilterIncludesChildren the child nodes of a matching node are shown as well. The value is saved with the form; the conditions are not, but AutoSaveLayout remembers them per Windows user.
Read/write.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
ColumnFilter property
Signature
Property Get ColumnFilter(ByVal Column As String) As String Property Let ColumnFilter(ByVal Column As String, RHS As String)
Summary
Gets or sets the condition of one column, in the format of the filter row.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Column | String | No | – | The name or field name of the column. |
Property value: String – The condition, for example >= 100, Bo* or leer; an empty string removes it.
Remarks
Reading returns the text of the filter row cell; for a condition from the value list it returns its short form. Setting text that does not fit the column raises wkeInvalidValue; an unknown column raises wkeKeyNotFound. Setting it from VBA raises no event.
The conditions apply in addition to Filter. A bound list that loads lazily (LazyLoad) sends them to the record source as part of a query, so nodes that are not loaded yet are found as well; the path to each match is loaded. A list that holds every record (LazyLoad False, GroupFields, a Recordset or a file) compares the loaded values. A condition the record source refuses raises wkeSourceError and leaves the filter as it was.
Read/write.
Code example
With Me!List1.Object
.ColumnFilter("Datenbank") = "BikeBuilder"
.ColumnFilter("Ergebnis") = "abgewiesen"
Debug.Print .ColumnFilterText
End With
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
ColumnFilterValues property
Signature
Property Get ColumnFilterValues(ByVal Column As String) As Variant Property Let ColumnFilterValues(ByVal Column As String, RHS As Variant)
Summary
Gets or sets the values of a column that pass the filter, as the value list in the column header selects them.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Column | String | No | – | The name or field name of the column. |
Property value: Variant – An array of values; Null or Empty removes the condition. Reading returns Empty when the column has no value condition.
Remarks
With AllowColumnFilter the funnel button in a column header opens the value list: every value with its number of records among those that the other conditions and Filter leave, a search box, and „(Select all)“. A list that loads lazily counts them in the record source. Ticking all values removes the condition.
Read/write.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
ColumnFilterEnabled property
Signature
Property Get ColumnFilterEnabled() As Boolean Property Let ColumnFilterEnabled(RHS As Boolean)
Summary
Gets or sets whether the column filter applies.
Parameters
None
Property value: Boolean – True (default) to filter; False to show all nodes without losing the conditions.
Remarks
The check box of the filter bar sets the same value.
Read/write.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
ColumnFilterText property
Signature
Property Get ColumnFilterText() As String
Summary
Gets the conditions of the column filter as text, as the filter bar shows them.
Parameters
None
Property value: String – For example [Datenbank] beginnt mit "BikeBuilder" und [Menge] >= 100; an empty string without a condition.
Remarks
Read-only.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
ClearColumnFilters method
Signature
Sub ClearColumnFilters()
Summary
Removes every column condition.
Parameters
None
Remarks
Filter stays as it is. Raises no event.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
ShowFilterBar property
Signature
Property Get ShowFilterBar() As Boolean Property Let ShowFilterBar(RHS As Boolean)
Summary
Gets or sets whether the filter bar appears below the records while columns are filtered.
Parameters
None
Property value: Boolean – True (default) to show the bar; False to hide it.
Remarks
The bar shows the column conditions as text, a check box that switches the column filter off and on, and the button „Clear filter“. With False the bar stays hidden; the conditions still apply. The value is saved with the form.
Read/write.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
FilterIncludesChildren property
Signature
Property Get FilterIncludesChildren() As Boolean Property Let FilterIncludesChildren(RHS As Boolean)
Summary
Gets or sets whether a node that meets the filter brings its child nodes along.
Parameters
None
Property value: Boolean – True to show a matching node with its child nodes and their descendants; False (default) to show it with its parent nodes only.
Remarks
Applies to every filter of the list: Filter, the column filter and Matches only of the search bar. The parent nodes of a match are always shown, so that the match can be seen in its place. With True, child nodes that are loaded later, when the user expands a match of a list that loads lazily, are shown as well. Changing the value applies the filter again. The value is saved with the form.
Read/write.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
AllowColumnFilter property
Signature
Property Get AllowColumnFilter() As Boolean Property Let AllowColumnFilter(RHS As Boolean)
Summary
Gets or sets whether the user can filter columns from their headers.
Parameters
None
Property value: Boolean – True to offer a value list in every column header with a field, and the filter commands in the shortcut menu of a column header; False (default) to offer neither.
Remarks
The shortcut menu of a column header then offers Show filter row, Clear the filter of the column, and Clear all column filters. The filter row (ShowFilterRow) and the members for VBA work in either case. WklGrid always offers the value list and has no such property. The value is saved with the form.
Read/write.
Code example
None
Inheritance
Declared by WklTreeList; also available on `WklGantt`.
CellClick event
Signature
Event CellClick(ByVal Key As Variant, ByVal Column As String)
Summary
Occurs when the user clicks a cell.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Key | Variant | No | – | The key of the node. |
Column | String | No | – | The column name. |
Remarks
In a form module: Private Sub <ControlName>_CellClick(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklTreeList.
CellDblClick event
Signature
Event CellDblClick(ByVal Key As Variant, ByVal Column As String)
Summary
Occurs when the user double-clicks a cell.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Key | Variant | No | – | The key of the node. |
Column | String | No | – | The column name. |
Remarks
In a form module: Private Sub <ControlName>_CellDblClick(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklTreeList.
BeforeCellEdit event
Signature
Event BeforeCellEdit(ByVal Key As Variant, ByVal Column As String, ByRef Cancel As Integer)
Summary
Occurs before the editor of a cell opens.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Key | Variant | No | – | The key of the node. |
Column | String | No | – | The column name. |
Cancel | Integer (by reference) | No | – | Set to True to keep the editor closed. |
Remarks
In a form module: Private Sub <ControlName>_BeforeCellEdit(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklTreeList.
ValidateCell event
Signature
Event ValidateCell(ByVal Key As Variant, ByVal Column As String, ByRef NewValue As Variant, ByRef Cancel As Integer)
Summary
Occurs after the user entered a value, before it is saved.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Key | Variant | No | – | The key of the node. |
Column | String | No | – | The column name. |
NewValue | Variant (by reference) | No | – | The entered value; the procedure can change it. |
Cancel | Integer (by reference) | No | – | Set to True to reject the value; nothing is saved. |
Remarks
In a form module: Private Sub <ControlName>_ValidateCell(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklTreeList.
AfterCellUpdate event
Signature
Event AfterCellUpdate(ByVal Key As Variant, ByVal Column As String)
Summary
Occurs after a cell value was saved.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Key | Variant | No | – | The key of the node. |
Column | String | No | – | The column name. |
Remarks
Raised only when the value changed: a cell opened and left with the value it had (also a double click and leaving it, or the same value typed again) is not written, as Access writes only changed fields. Null and an empty value of the source count as the same, numbers are compared by their value, text exactly (a change of case is a change).
In a form module: Private Sub <ControlName>_AfterCellUpdate(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklTreeList.
ColumnClick event
Signature
Event ColumnClick(ByVal Column As String, ByRef Cancel As Integer)
Summary
Occurs when the user clicks a column header, before the list is sorted by it.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Column | String | No | – | The column name. |
Cancel | Integer (by reference) | No | – | Set to True to prevent sorting. |
Remarks
In a form module: Private Sub <ControlName>_ColumnClick(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklTreeList.
ColumnResize event
Signature
Event ColumnResize(ByVal Column As String, ByVal Width As Long)
Summary
Occurs after the user changed the width of a column.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Column | String | No | – | The column name. |
Width | Long | No | – | The new width in twips. |
Remarks
In a form module: Private Sub <ControlName>_ColumnResize(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklTreeList.
ColumnMove event
Signature
Event ColumnMove(ByVal Column As String, ByVal VisibleIndex As Long)
Summary
Occurs after the user moved a column.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Column | String | No | – | The column name. |
VisibleIndex | Long | No | – | The new display position. |
Remarks
In a form module: Private Sub <ControlName>_ColumnMove(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklTreeList.
CellFormat event
Signature
Event CellFormat(ByVal Key As Variant, ByVal Column As String, ByRef ForeColor As Long, ByRef BackColor As Long, ByRef Bold As Boolean, ByRef Italic As Boolean)
Summary
Occurs before a cell is shown, to format it.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Key | Variant | No | – | The key of the node. |
Column | String | No | – | The column name. |
ForeColor | Long (by reference) | No | – | The text color; -1 for the default. The procedure can change it. |
BackColor | Long (by reference) | No | – | The background color; -1 for the default. The procedure can change it. |
Bold | Boolean (by reference) | No | – | True for bold text; the procedure can change it. |
Italic | Boolean (by reference) | No | – | True for italic text; the procedure can change it. |
Remarks
Raised only with FormatEvents = True, for every visible cell on every redraw. Format rules (FormatRules) need no event.
In a form module: Private Sub <ControlName>_CellFormat(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklTreeList.
FocusedCellChange event
Signature
Event FocusedCellChange(ByVal Key As Variant, ByVal Column As String)
Summary
Occurs when the focused cell changes.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Key | Variant | No | – | The key of the node. |
Column | String | No | – | The column name. |
Remarks
In a form module: Private Sub <ControlName>_FocusedCellChange(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklTreeList.
CommandStateChange event
Signature
Event CommandStateChange()
Summary
Occurs when CanAdd, CanDelete, CanEdit or CanExport has changed, so that the form can enable or disable its own buttons.
Parameters
None
Remarks
Unlike the other events it also occurs after changes by code (another selected record, AllowDeletions, Requery), because a button must follow every change. It occurs once the change is complete, never while a property is being set, and several changes at once give one event. It does not occur when the form opens: read the four properties in Form_Load. What the program has read counts as reported: a change from the value read last raises the event, also before the control has been drawn for the first time and while Access runs hidden (Application.Visible = False). While the control itself is hidden, changes are reported when it is shown again.
In a form module: Private Sub <ControlName>_CommandStateChange(...). Parameters passed by reference can be changed by the procedure.
Code example
Private Sub Grid1_CommandStateChange()
With Me!Grid1.Object
Me!cmdNew.Enabled = .CanAdd
Me!cmdDelete.Enabled = .CanDelete
Me!cmdExport.Enabled = .CanExport
End With
End Sub
Inheritance
Declared by WklTreeList.
BeforeContextMenu event
Signature
Event BeforeContextMenu(ByVal Key As Variant, ByVal Column As String, ByRef Cancel As Integer)
Summary
Occurs before the shortcut menu opens: after a right click, the menu key, Shift+F10 or ShowContextMenu, also in a detail view.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Key | Variant | No | – | The key of the record the menu opens on; Null on a group row. |
Column | String | No | – | The column name; empty outside a cell. |
Cancel | Integer (by reference) | No | – | Set to True to show no menu. |
Remarks
ContextKey, ContextColumn and ContextView are already set, so the procedure can enable, check or hide custom items for this record before the menu is built. After a right click, NodeRightClick (RowRightClick in a WklGrid) occurs first; its Cancel suppresses the menu as well. In a detail view of a WklGrid the master grid raises the event. Like all events of the control it needs the form's module; the menu itself works without it.
In a form module: Private Sub <ControlName>_BeforeContextMenu(...). Parameters passed by reference can be changed by the procedure.
Code example
Private Sub Grid1_BeforeContextMenu(ByVal Key As Variant, ByVal Column As String, Cancel As Integer)
If IsNull(Key) Then Exit Sub
Me!Grid1.Object.MenuItemEnabled("print") = Not IsNull(DLookup("ShippedOn", "tblOrders", "OrderID = " & Key))
End Sub
Inheritance
Declared by WklTreeList.
BeforeEditForm event
Signature
Event BeforeEditForm(ByVal Key As Variant, ByRef FormName As String, ByRef Cancel As Integer)
Summary
Occurs before the edit form opens.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Key | Variant | No | – | The key of the record; Null for a new record. |
FormName | String (by reference) | No | – | The form that will open; set it to open another form. |
Cancel | Integer (by reference) | No | – | Set to True to open nothing. |
Remarks
A form set in FormName is limited to the record over the list's KeyField (its own key fields are unknown to the list). Like all events of the control it needs the form's module; the edit form itself works without it.
In a form module: Private Sub <ControlName>_BeforeEditForm(...). Parameters passed by reference can be changed by the procedure.
Code example
Private Sub Grid1_BeforeEditForm(ByVal Key As Variant, FormName As String, Cancel As Integer)
If Not IsNull(Key) Then
If DLookup("Locked", "tblCustomer", "ID = " & Key) Then FormName = "frmCustomerReadOnly"
End If
End Sub
Inheritance
Declared by WklTreeList.
AfterEditForm event
Signature
Event AfterEditForm(ByVal Key As Variant, ByVal NewRecord As Boolean)
Summary
Occurs after the edit form has been closed and the list has read its records again.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Key | Variant | No | – | The key of the record that was edited; Null for a new record. |
NewRecord | Boolean | No | – | True when the form was opened for a new record. |
Remarks
The event occurs when the dialog of wfmDialog or wfmAuto is closed, when the window of wfmWindow is closed (the list notices it within half a second), and when the focus comes back from the docked or overlaying form. A form window that stays open and is opened again for another record reports the last one. EditFormResult tells what became of the record; a record the form added is selected and its key is in EditFormNewKey.
In a form module: Private Sub <ControlName>_AfterEditForm(...). Parameters passed by reference can be changed by the procedure.
Code example
Private Sub Grid1_AfterEditForm(ByVal Key As Variant, ByVal NewRecord As Boolean)
If Me!Grid1.Object.EditFormResult <> wfrUnchanged Then Me!txtCount = Me!Grid1.Object.RecordCount
End Sub
Inheritance
Declared by WklTreeList.
ValidationChange event
Signature
Event ValidationChange()
Summary
Occurs when the errors shown have changed.
Parameters
None
Remarks
After a rule refused an input or is met again, after SetError and ClearErrors, and after a write the data source refused. Read ErrorCount and ErrorSummary for your own summary. Like all events of the control it needs the form's module.
In a form module: Private Sub <ControlName>_ValidationChange(...). Parameters passed by reference can be changed by the procedure.
Code example
Private Sub Grid1_ValidationChange()
Me!lblFehler.Caption = Me!Grid1.Object.ErrorSummary
End Sub
Inheritance
Declared by WklTreeList.
BeforeColumnFilter event
Signature
Event BeforeColumnFilter(ByVal Column As String, ByVal Text As String, ByRef Cancel As Integer)
Summary
Occurs when the user changes the column filter, before the nodes are filtered.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Column | String | No | – | The name of the column; an empty string when the change applies to all columns (filter bar). |
Text | String | No | – | The condition as the filter row shows it; an empty string when it is removed. |
Cancel | Integer (by reference) | No | – | Set to True to discard the change. |
Remarks
Raised for the filter row, the value list in a column header, the shortcut menu of a column header and the filter bar; not for changes made from VBA.
In a form module: Private Sub <ControlName>_BeforeColumnFilter(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklTreeList.
AfterColumnFilter event
Signature
Event AfterColumnFilter()
Summary
Occurs after the user changed the column filter and the nodes were filtered.
Parameters
None
Remarks
In a form module: Private Sub <ControlName>_AfterColumnFilter(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklTreeList.