WklStatusLabel
WklStatusLabel class
Signature
Dim myWklStatusLabel As WklStatusLabel Set myWklStatusLabel = Me!ControlName.Object
Summary
A status in one line: a text with a kind - neutral, ok, warn, bad or info - that sets its colors, shown as a pill, as a dot before the text, or as a symbol before the text, with an optional caption in front and a busy pulse.
Parameters
None
Remarks
The label draws the same pills and colors as a status column of WklGrid (wedStatus), so a status looks the same in a list and on its own. Color is never the only statement: the text is always drawn, and screen readers hear caption, text and kind.
Fill it in one of two ways:
- Unbound: set
Text,KindandGlyphin the property sheet, in the designer or by code. - Bound: set the label's Control Source (
ControlSourceof the Access control) to a field or an expression. Access writes the value of the current record intoValueon every record change. The label turns it into text, kind and symbol: an entry added withAddStatusItemwhose value matches decides all three; without an entry, the text is the value formatted withFormat(NullTextfor Null), and the kind comes from the field named inKindField, or else is the designedKind. The designedKindandGlyphstay the fallback for every record, so a record without an entry never keeps the colors of the record before it.
A bound label never writes back and does not mark the record as changed (checked in Access), so an expression or a read-only field as Control Source is fine.
The designer (row Custom [...] of the property sheet in design view, Opening the designer) edits the designed status with a preview, the entries as a table (value, text, kind, symbol; a whole number is compared as a number, anything else as text), KindField, Format, NullText, the color scheme, appearance and behavior. OK writes every changed property into the form; a value used twice or an invalid symbol code keeps the designer open and names the row.
Use the label in single forms, in the header or footer of any form, and unbound anywhere. Do not put a bound label - or any bound WKL control - into the detail section of a continuous form: Access creates one instance there that shows only the current record, and with a Control Source in the detail section Access does not finish opening the form; it stops before the WKL code is loaded. For a status per record use a status column of WklGrid. A bound label in the form header of a continuous form works and follows the current record.
The label also works on Excel and Word UserForms; there is no form record there, so KindField has no effect and the designed Kind applies.
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 |
|---|---|---|
| `Text` | Property | Gets or sets the text the label shows. |
| `Kind` | Property | Gets or sets the kind of the status, which sets its colors. |
| `Glyph` | Property | Gets or sets a symbol drawn before the text. |
| `Display` | Property | Gets or sets how the label shows its kind. |
| `Busy` | Property | Gets or sets whether the label shows a running activity. |
| `Value` | Property | Gets or sets the bound value: Access writes the value of the Control Source into it on every record change. |
| `KindField` | Property | Gets or sets the name of a field or control of the form whose value is the kind of the status. |
| `Format` | Property | Gets or sets the format of the value, as the Format property of an Access text box. |
| `NullText` | Property | Gets or sets the text shown when the value is Null. |
| `Caption` | Property | Gets or sets a plain text in front of the status, for example “Dienst”. |
| `Alignment` | Property | Gets or sets where caption and status sit in the label. |
| `BackColor` | Property | Gets or sets the background color of the label. |
| `ForeColor` | Property | Gets or sets the color of the caption and of the text beside a dot or symbol. |
| `FontName` | Property | Gets or sets the font of caption and text. |
| `FontSize` | Property | Gets or sets the size of caption and text. |
| `Clickable` | Property | Gets or sets whether the label behaves like a link. |
| `Announce` | Property | Gets or sets whether screen readers announce changes. |
| `AddStatusItem` | Method | Adds an entry that says how one value of Value is shown. |
| `ClearStatusItems` | Method | Removes all entries. |
| `StatusItemCount` | Property | Returns the number of entries. |
| `Refresh` | Method | Reads KindField again and shows the current value anew, for example after code changed the kind field of the current record without moving to another record. |
| `ColorScheme` | Property | Gets or sets the color scheme the control draws in. |
| Event | Summary |
|---|---|
| `Click` | Occurs when the user clicks the label; for a Clickable label also on Enter or Space while it has the focus, and when a screen reader or test tool invokes it. |
Code example
' Bound to the field Zustand; the entries turn its values into text, kind and symbol.
' The entries are usually set once in the designer (page Werte) and are stored with the form.
Private Sub Form_Load()
With Me!lblZustand.Object
.Caption = "Dienst"
.NullText = "unbekannt"
.ClearStatusItems
.AddStatusItem "running", "running", wskOk, "E768"
.AddStatusItem "startet", "startet", wskWarn
.AddStatusItem "failed", "down", wskBad, "E783"
End With
End Sub
Inheritance
None
Text property
Signature
Property Get Text() As String Property Let Text(RHS As String)
Summary
Gets or sets the text the label shows.
Parameters
None
Property value: String – Any text; empty shows nothing (in design view a dotted placeholder).
Remarks
For a bound label the text comes from Value on every record change; setting Text by code shows it until the next value arrives. In design view the text is stored with the form.
Read/write.
Code example
None
Inheritance
Declared by WklStatusLabel.
Kind property
Signature
Property Get Kind() As WklStatusKind Property Let Kind(RHS As WklStatusKind)
Summary
Gets or sets the kind of the status, which sets its colors.
Parameters
None
Property value: `WklStatusKind` – wskNeutral (default), wskOk, wskWarn, wskBad, wskInfo or wskMuted.
Remarks
For a bound label the property returns the kind of the current record (from an entry or KindField); the designed value applies to records without an entry and without KindField. Values outside 0-4 raise wkeInvalidValue.
Read/write.
Code example
None
Inheritance
Declared by WklStatusLabel.
Glyph property
Signature
Property Get Glyph() As String Property Let Glyph(RHS As String)
Summary
Gets or sets a symbol drawn before the text.
Parameters
None
Property value: String – The hexadecimal code of a glyph of Segoe Fluent Icons (Windows 11) or Segoe MDL2 Assets (Windows 10), for example "E768" (play) or "E946" (info); also with a prefix ("&HE768", "U+E768"); empty (default) for no symbol.
Remarks
Only codes from U+E000 to U+F8FF, where both symbol fonts keep their glyphs, are accepted; others raise wkeInvalidValue. A glyph shows in the pill and in the symbol display; the dot display ignores it.
Read/write.
Code example
None
Inheritance
Declared by WklStatusLabel.
Display property
Signature
Property Get Display() As WklStatusDisplay Property Let Display(RHS As WklStatusDisplay)
Summary
Gets or sets how the label shows its kind.
Parameters
None
Property value: `WklStatusDisplay` – wsdPill (default), wsdDot or wsdSymbol.
Remarks
The symbol display without a glyph, or on a computer without symbol font, falls back to the dot.
Read/write.
Code example
None
Inheritance
Declared by WklStatusLabel.
Busy property
Signature
Property Get Busy() As Boolean Property Let Busy(RHS As Boolean)
Summary
Gets or sets whether the label shows a running activity.
Parameters
None
Property value: Boolean – True: the colored part pulses and “ …” follows the text; False (default).
Remarks
When Windows animations are switched off (Settings › Accessibility › Visual effects), the label does not pulse; the ellipsis and the screen reader state “busy” remain, so the state never rests on motion. The pulse runs only while the label is visible in form view and stops when its form or subform closes.
Read/write.
Code example
None
Inheritance
Declared by WklStatusLabel.
Value property
Signature
Property Get Value() As Variant Property Let Value(RHS As Variant)
Summary
Gets or sets the bound value: Access writes the value of the Control Source into it on every record change.
Parameters
None
Property value: Variant – Any value, or Null.
Remarks
Code may set Value as well, for example in an unbound label; the label then derives text, kind and symbol as for a bound value. The value is not stored with the form, and the label never reports it back to Access.
Read/write.
Code example
None
Inheritance
Declared by WklStatusLabel.
KindField property
Signature
Property Get KindField() As String Property Let KindField(RHS As String)
Summary
Gets or sets the name of a field or control of the form whose value is the kind of the status.
Parameters
None
Property value: String – A field of the form's record source (with or without a control) or a control name; empty (default) for none. The field holds a number 0-4 or a name: neutral, ok, warn or warning, bad or error, info (case does not matter); any other value, Null included, counts as neutral.
Remarks
The field is read whenever a value arrives, through the form member of that name (as Me!Art in VBA), so it belongs to the same record as the value. An entry for the value takes precedence over the field. A field changed by code on the same record reaches the label after Refresh. On a new record, on a report and on UserForms the designed Kind applies.
Read/write.
Code example
None
Inheritance
Declared by WklStatusLabel.
Format property
Signature
Property Get Format() As String Property Let Format(RHS As String)
Summary
Gets or sets the format of the value, as the Format property of an Access text box.
Parameters
None
Property value: String – An Access format such as "Standard", "0 %", "Short Date" or "#,##0 \"sessions\""; empty (default) for the general format. Numbers and dates follow the regional settings of Windows.
Remarks
The format applies to values without an entry and to entries without a text of their own.
Read/write.
Code example
None
Inheritance
Declared by WklStatusLabel.
NullText property
Signature
Property Get NullText() As String Property Let NullText(RHS As String)
Summary
Gets or sets the text shown when the value is Null.
Parameters
None
Property value: String – Any text; empty (default) shows nothing.
Remarks
Read/write.
Code example
None
Inheritance
Declared by WklStatusLabel.
Caption property
Signature
Property Get Caption() As String Property Let Caption(RHS As String)
Summary
Gets or sets a plain text in front of the status, for example “Dienst”.
Parameters
None
Property value: String – Any text; empty (default) for none.
Remarks
The caption is drawn in ForeColor and is part of the name screen readers hear: “Service: running”.
Read/write.
Code example
None
Inheritance
Declared by WklStatusLabel.
Alignment property
Signature
Property Get Alignment() As WklAlignment Property Let Alignment(RHS As WklAlignment)
Summary
Gets or sets where caption and status sit in the label.
Parameters
None
Property value: `WklAlignment` – walGeneral (default) and walLeft place them left, walCenter centered, walRight right.
Remarks
Read/write.
Code example
None
Inheritance
Declared by WklStatusLabel.
BackColor property
Signature
Property Get BackColor() As OLE_COLOR Property Let BackColor(RHS As OLE_COLOR)
Summary
Gets or sets the background color of the label.
Parameters
None
Property value: OLE_COLOR – An OLE_COLOR; default the system color for windows (vbWindowBackground).
Remarks
Set it to the color of the section the label sits in. In Windows high contrast mode the label uses the system colors instead.
Read/write.
Code example
None
Inheritance
Declared by WklStatusLabel.
ForeColor property
Signature
Property Get ForeColor() As OLE_COLOR Property Let ForeColor(RHS As OLE_COLOR)
Summary
Gets or sets the color of the caption and of the text beside a dot or symbol.
Parameters
None
Property value: OLE_COLOR – An OLE_COLOR; default the system color for window text (vbWindowText).
Remarks
Pill texts and symbols use the colors of their kind, which keep a contrast of at least 4.5:1.
Read/write.
Code example
None
Inheritance
Declared by WklStatusLabel.
FontName property
Signature
Property Get FontName() As String Property Let FontName(RHS As String)
Summary
Gets or sets the font of caption and text.
Parameters
None
Property value: String – A font name; default "Segoe UI". An empty name raises wkeInvalidValue.
Remarks
The text in a pill uses Segoe UI Semibold at the same size, as in WklGrid.
Read/write.
Code example
None
Inheritance
Declared by WklStatusLabel.
FontSize property
Signature
Property Get FontSize() As Long Property Let FontSize(RHS As Long)
Summary
Gets or sets the size of caption and text.
Parameters
None
Property value: Long – Points from 6 to 72; default 9. Other values raise wkeInvalidValue.
Remarks
Read/write.
Code example
None
Inheritance
Declared by WklStatusLabel.
Clickable property
Signature
Property Get Clickable() As Boolean Property Let Clickable(RHS As Boolean)
Summary
Gets or sets whether the label behaves like a link.
Parameters
None
Property value: Boolean – True: the status text is underlined, the mouse pointer is a hand, Enter and Space raise Click when the label has the focus, and screen readers announce a link that can be invoked; False (default).
Remarks
Click occurs on a mouse click in either case; Clickable adds the look, the keys and the invoke action of a link.
Read/write.
Code example
None
Inheritance
Declared by WklStatusLabel.
Announce property
Signature
Property Get Announce() As Boolean Property Let Announce(RHS As Boolean)
Summary
Gets or sets whether screen readers announce changes.
Parameters
None
Property value: Boolean – True (default): a change of text or kind is announced politely (UI Automation live region); a record whose status equals the one before is not announced again. False: no announcements.
Remarks
Switch it off for labels that change with every record of a list a user scrolls through quickly.
Read/write.
Code example
None
Inheritance
Declared by WklStatusLabel.
AddStatusItem method
Signature
Sub AddStatusItem(ByVal Value As Variant, ByVal Text As String, Optional ByVal Kind As WklStatusKind = wskNeutral, Optional ByVal Glyph As String = "")
Summary
Adds an entry that says how one value of Value is shown.
Parameters
| Name | Type | Optional | Default | Description |
|---|---|---|---|---|
Value | Variant | No | – | The value the entry stands for; numbers compare by value whatever their type, text without regard to case. Null raises wkeInvalidValue. |
Text | String | No | – | The text shown; empty shows the value formatted with Format. |
Kind | `WklStatusKind` | Yes | wskNeutral | The kind, wskNeutral if omitted. |
Glyph | String | Yes | "" | A glyph code; empty if omitted, which keeps the label's own Glyph. |
Remarks
A second entry for the same value replaces the first. Entries added in design view are stored with the form. The entries work like those of a WklGrid status column (WklColumn.AddStatusItem), so the same values can feed both.
Code example
None
Inheritance
Declared by WklStatusLabel.
ClearStatusItems method
Signature
Sub ClearStatusItems()
Summary
Removes all entries.
Parameters
None
Remarks
None
Code example
None
Inheritance
Declared by WklStatusLabel.
StatusItemCount property
Signature
Property Get StatusItemCount() As Long
Summary
Returns the number of entries.
Parameters
None
Property value: Long – 0 or more.
Remarks
Read-only.
Code example
None
Inheritance
Declared by WklStatusLabel.
Refresh method
Signature
Sub Refresh()
Summary
Reads KindField again and shows the current value anew, for example after code changed the kind field of the current record without moving to another record.
Parameters
None
Remarks
None
Code example
None
Inheritance
Declared by WklStatusLabel.
ColorScheme property
Signature
Property Get ColorScheme() As WklColorScheme Property Let ColorScheme(RHS As WklColorScheme)
Summary
Gets or sets the color scheme the control draws in.
Parameters
None
Property value: `WklColorScheme` – wcoAutomatic (default), wcoLight, wcoDark or wcoHighContrast.
Remarks
wcoAutomatic follows, in this order, Windows high contrast mode, then the color set of the database design (Access: Design › Themes or Colors), and draws light when the database has no design or the control is on an Excel or Word UserForm. Office's own design setting and the Windows app mode are not followed: a database looks the same on every PC. In high contrast mode the control always uses the system colors. The scheme colors the background and the text of the caption while BackColor and ForeColor keep their system defaults (light keeps the system colors); the status colors of pill, dot and symbol stay, because the text carries their meaning; a BackColor you set wins over the scheme. Every text keeps a contrast of at least 4.5:1. The control reads the database design after it is first drawn, never while Access draws the form, and again when the form opens anew. The value is saved with the form.
Read/write.
Code example
None
Inheritance
Declared by WklStatusLabel.
Click event
Signature
Event Click()
Summary
Occurs when the user clicks the label; for a Clickable label also on Enter or Space while it has the focus, and when a screen reader or test tool invokes it.
Parameters
None
Remarks
In a form module: Private Sub <ControlName>_Click(...). Parameters passed by reference can be changed by the procedure.
Code example
None
Inheritance
Declared by WklStatusLabel.