Color scheme: Riviera
You are here: start » en » Documentation » Microsoft Access development tools » WKL Forms Object Library » WKL Forms Object Library API reference » WklGauge

WklGauge

WklGauge class

Signature

Dim myWklGauge As WklGauge
Set myWklGauge = Me!ControlName.Object

Summary

A value on a scale with colored ranges: a half or three-quarter circle, or a horizontal or vertical bar with further bars and a legend.

Parameters

None

Remarks

Use it for a load, a fill level or a count against a limit on a start page or a status page. The ranges (AddRange) decide the color: the value is drawn in the strong color of the kind of the range it lies in, so a gauge, a status label and a badge show “warn” in the same amber. Outside every range the color is neutral.

Fill it in one of two ways: unbound, code sets Value (for example from a timer that reads a service); bound, Control Source names a field or expression and Access writes it into Value on every record change. Value is never written back, so a calculated control source works.

A new value glides to its place in a quarter of a second, unless Animate is False or Windows animations are off. When the value moves into another range, RangeChange occurs and, with Announce, screen readers hear the new statement; a new value in the same range is not announced, so a gauge updated every second stays quiet. UI Automation presents a progress bar whose name is the whole statement (Statement) and whose range value is the number between Min and Max.

A horizontal or vertical gauge can show further bars (AddBar, BarValue), each in its own kind, side by side or stacked, with a legend. The values of the bars belong to the running form and are not saved with it; the bars themselves (key, caption, kind) are.

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.

MemberKindSummary
`Value`PropertyGets or sets the value shown on the scale.
`Min`PropertyGets or sets the start of the scale.
`Max`PropertyGets or sets the end of the scale.
`Shape`PropertyGets or sets the outline of the gauge.
`Style`PropertyGets or sets how the gauge shows its value.
`Caption`PropertyGets or sets the caption above the gauge.
`Unit`PropertyGets or sets the unit after the value.
`Format`PropertyGets or sets the format of the value.
`Hint`PropertyGets or sets a line under the value.
`Marker`PropertyGets or sets a mark on the scale, for example a target or a limit.
`Animate`PropertyGets or sets whether new values glide to their place.
`ShowValue`PropertyGets or sets whether value and unit are shown in the center or next to the bar.
`BackColor`PropertyGets or sets the background color.
`ForeColor`PropertyGets or sets the color of caption, value, hint, needle and marker.
`FontName`PropertyGets or sets the font.
`FontSize`PropertyGets or sets the font size of the caption, in points.
`Announce`PropertyGets or sets whether screen readers hear a change of range.
`AddRange`MethodAdds a colored range to the scale.
`ClearRanges`MethodRemoves all ranges.
`RangeCount`PropertyGets the number of ranges.
`AddBar`MethodAdds a further bar to a horizontal or vertical gauge, or changes caption and kind of the bar with this key.
`BarValue`PropertyGets or sets the value of a bar.
`RemoveBar`MethodRemoves a bar.
`ClearBars`MethodRemoves all bars.
`BarCount`PropertyGets the number of bars.
`Stacked`PropertyGets or sets whether the bars are stacked into one bar.
`ShowLegend`PropertyGets or sets whether the legend of the bars is shown.
`Statement`PropertyGets the statement screen readers hear.
`Key`PropertyGets or sets the key that Click passes on.
`ColorScheme`PropertyGets or sets the color scheme the control draws in.
`PrintStyle`PropertyGets or sets when the ranges are told apart by pattern as well as by color.
EventSummary
`Click`Occurs when the user clicks the gauge.
`RangeChange`Occurs when the value moves into another range.

Code example

Private Sub Form_Load()
    With Me!gauCpu.Object
        .Caption = "CPU"
        .Unit = "%"
        .AddRange 0, 70, wskOk, True
        .AddRange 70, 90, wskWarn, True
        .AddRange 90, 100, wskBad, True
        .Marker = 80
        .Key = "cpu"
    End With
End Sub
 
Private Sub Form_Timer()
    Me!gauCpu.Object.Value = DLookup("Cpu", "qryServiceStatus")
End Sub

Inheritance

None

Value property

Signature

Property Get Value() As Variant
Property Let Value(RHS As Variant)

Summary

Gets or sets the value shown on the scale.

Parameters

None

Property value: Variant – A number, or Null for no value (“–” is shown and nothing is filled).

Remarks

A value below Min or above Max is drawn at the end of the scale and marked; Statement adds “Below the minimum” or “maximum exceeded”. Text and other values raise wkeInvalidValue; an empty text counts as Null.

Read/write.

Code example

None

Inheritance

Declared by WklGauge.

Min property

Signature

Property Get Min() As Double
Property Let Min(RHS As Double)

Summary

Gets or sets the start of the scale.

Parameters

None

Property value: Double – A number; the default is 0.

Remarks

Min and Max can be set in any order. While Max is not greater than Min, the gauge draws “Check Min/Max” and Statement says what is wrong.

Read/write.

Code example

None

Inheritance

Declared by WklGauge.

Max property

Signature

Property Get Max() As Double
Property Let Max(RHS As Double)

Summary

Gets or sets the end of the scale.

Parameters

None

Property value: Double – A number greater than Min; the default is 100.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklGauge.

Shape property

Signature

Property Get Shape() As WklGaugeShape
Property Let Shape(RHS As WklGaugeShape)

Summary

Gets or sets the outline of the gauge.

Parameters

None

Property value: `WklGaugeShape` – A `WklGaugeShape` constant; the default is wgeHalfCircle.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklGauge.

Style property

Signature

Property Get Style() As WklGaugeStyle
Property Let Style(RHS As WklGaugeStyle)

Summary

Gets or sets how the gauge shows its value.

Parameters

None

Property value: `WklGaugeStyle` – A `WklGaugeStyle` constant; the default is wgfFill.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklGauge.

Caption property

Signature

Property Get Caption() As String
Property Let Caption(RHS As String)

Summary

Gets or sets the caption above the gauge.

Parameters

None

Property value: String – A text, for example “CPU”; empty for none.

Remarks

The caption also starts the statement for screen readers (“CPU: 87 %, Warnung”).

Read/write.

Code example

None

Inheritance

Declared by WklGauge.

Unit property

Signature

Property Get Unit() As String
Property Let Unit(RHS As String)

Summary

Gets or sets the unit after the value.

Parameters

None

Property value: String – A text such as “%”, “ms” or “sessions”; empty for none.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklGauge.

Format property

Signature

Property Get Format() As String
Property Let Format(RHS As String)

Summary

Gets or sets the format of the value.

Parameters

None

Property value: String – An Access format such as “0.0” or “#,##0”; empty for the general format.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklGauge.

Hint property

Signature

Property Get Hint() As String
Property Let Hint(RHS As String)

Summary

Gets or sets a line under the value.

Parameters

None

Property value: String – A text, for example “Mittel 5 min”; empty for none.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklGauge.

Marker property

Signature

Property Get Marker() As Variant
Property Let Marker(RHS As Variant)

Summary

Gets or sets a mark on the scale, for example a target or a limit.

Parameters

None

Property value: Variant – A number, or Null (default) for no mark.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklGauge.

Animate property

Signature

Property Get Animate() As Boolean
Property Let Animate(RHS As Boolean)

Summary

Gets or sets whether new values glide to their place.

Parameters

None

Property value: Boolean – True (default) or False.

Remarks

The movement is off when Windows animations are off (Settings › Accessibility › Visual effects), in design view and when printing.

Read/write.

Code example

None

Inheritance

Declared by WklGauge.

ShowValue property

Signature

Property Get ShowValue() As Boolean
Property Let ShowValue(RHS As Boolean)

Summary

Gets or sets whether value and unit are shown in the center or next to the bar.

Parameters

None

Property value: Boolean – True (default) or False.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklGauge.

BackColor property

Signature

Property Get BackColor() As OLE_COLOR
Property Let BackColor(RHS As OLE_COLOR)

Summary

Gets or sets the background color.

Parameters

None

Property value: OLE_COLOR – A color number; the default is the window background.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklGauge.

ForeColor property

Signature

Property Get ForeColor() As OLE_COLOR
Property Let ForeColor(RHS As OLE_COLOR)

Summary

Gets or sets the color of caption, value, hint, needle and marker.

Parameters

None

Property value: OLE_COLOR – A color number; the default is the window text color.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklGauge.

FontName property

Signature

Property Get FontName() As String
Property Let FontName(RHS As String)

Summary

Gets or sets the font.

Parameters

None

Property value: String – A font name; the default is “Segoe UI”.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklGauge.

FontSize property

Signature

Property Get FontSize() As Long
Property Let FontSize(RHS As Long)

Summary

Gets or sets the font size of the caption, in points.

Parameters

None

Property value: Long – 6 to 72; the default is 9. The value in the center is drawn twice as large.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklGauge.

Announce property

Signature

Property Get Announce() As Boolean
Property Let Announce(RHS As Boolean)

Summary

Gets or sets whether screen readers hear a change of range.

Parameters

None

Property value: Boolean – True (default) or False.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklGauge.

AddRange method

Signature

Sub AddRange(ByVal From As Double, ByVal To As Double, ByVal Kind As WklStatusKind, Optional ByVal Percent As Boolean = False)

Summary

Adds a colored range to the scale.

Parameters

NameTypeOptionalDefaultDescription
FromDoubleNo–The start of the range.
ToDoubleNo–The end of the range; the ends may be given in either order.
Kind`WklStatusKind`No–A `WklStatusKind` constant; sets the colors.
PercentBooleanYesFalseTrue when From and To are percent of Min to Max; False (default) for values of the scale.

Remarks

Ranges are drawn as pale bands of their kind behind the value. Where ranges overlap, the one added last decides the color. A kind outside the enumeration raises wkeInvalidValue.

Code example

None

Inheritance

Declared by WklGauge.

ClearRanges method

Signature

Sub ClearRanges()

Summary

Removes all ranges.

Parameters

None

Remarks

None

Code example

None

Inheritance

Declared by WklGauge.

RangeCount property

Signature

Property Get RangeCount() As Long

Summary

Gets the number of ranges.

Parameters

None

Property value: Long – The number of ranges.

Remarks

Read-only.

Code example

None

Inheritance

Declared by WklGauge.

AddBar method

Signature

Sub AddBar(ByVal Key As String, ByVal Caption As String, Optional ByVal Kind As WklStatusKind = wskNeutral)

Summary

Adds a further bar to a horizontal or vertical gauge, or changes caption and kind of the bar with this key.

Parameters

NameTypeOptionalDefaultDescription
KeyStringNo–A key that BarValue uses; case is ignored, as in Access names.
CaptionStringNo–The caption in the legend.
Kind`WklStatusKind`YeswskNeutralA `WklStatusKind` constant; sets the color of the bar (default wskNeutral).

Remarks

A gauge with bars shows them instead of Value; a circular gauge ignores bars. An existing bar keeps its value when it is added again.

Code example

None

Inheritance

Declared by WklGauge.

BarValue property

Signature

Property Get BarValue(ByVal Key As String) As Variant
Property Let BarValue(ByVal Key As String, RHS As Variant)

Summary

Gets or sets the value of a bar.

Parameters

NameTypeOptionalDefaultDescription
KeyStringNo–The key of the bar.

Property value: Variant – A number, or Null for no value.

Remarks

An unknown key raises wkeKeyNotFound; a value that is no number raises wkeInvalidValue. Bar values are not saved with the form.

Read/write.

Code example

None

Inheritance

Declared by WklGauge.

RemoveBar method

Signature

Sub RemoveBar(ByVal Key As String)

Summary

Removes a bar.

Parameters

NameTypeOptionalDefaultDescription
KeyStringNo–The key of the bar; an unknown key raises wkeKeyNotFound.

Remarks

None

Code example

None

Inheritance

Declared by WklGauge.

ClearBars method

Signature

Sub ClearBars()

Summary

Removes all bars.

Parameters

None

Remarks

None

Code example

None

Inheritance

Declared by WklGauge.

BarCount property

Signature

Property Get BarCount() As Long

Summary

Gets the number of bars.

Parameters

None

Property value: Long – The number of bars.

Remarks

Read-only.

Code example

None

Inheritance

Declared by WklGauge.

Stacked property

Signature

Property Get Stacked() As Boolean
Property Let Stacked(RHS As Boolean)

Summary

Gets or sets whether the bars are stacked into one bar.

Parameters

None

Property value: Boolean – True for one stacked bar; False (default) for one bar per key.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklGauge.

ShowLegend property

Signature

Property Get ShowLegend() As Boolean
Property Let ShowLegend(RHS As Boolean)

Summary

Gets or sets whether the legend of the bars is shown.

Parameters

None

Property value: Boolean – True (default) or False.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklGauge.

Statement property

Signature

Property Get Statement() As String

Summary

Gets the statement screen readers hear.

Parameters

None

Property value: String – For example “CPU: 87 %, Warnung”, “CPU: kein Wert”, or for bars “Letzte 5 Minuten: Abweisungen 12, Fehler 3”.

Remarks

Read-only.

Code example

None

Inheritance

Declared by WklGauge.

Key property

Signature

Property Get Key() As String
Property Let Key(RHS As String)

Summary

Gets or sets the key that Click passes on.

Parameters

None

Property value: String – A text, for example the name of the list a click opens; empty by default.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklGauge.

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 background and text (while BackColor and ForeColor keep the system defaults), the track, the range bands and the fills; 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 WklGauge.

PrintStyle property

Signature

Property Get PrintStyle() As WklPrintStyle
Property Let PrintStyle(RHS As WklPrintStyle)

Summary

Gets or sets when the ranges are told apart by pattern as well as by color.

Parameters

None

Property value: `WklPrintStyle` – wpsAutomatic (default), wpsColor or wpsPatterns.

Remarks

On a black-and-white or grayscale printout colors of similar lightness become the same gray. With patterns, each range carries a hatch of its status kind (bad cross-hatched and darkest, warn diagonal, ok dotted), the value fill carries the hatch of its range, and the track is outlined with a mark where two ranges meet. wpsAutomatic draws them only for a printer, a PDF or the print preview of a report; on the screen the control stays in color. wpsPatterns draws them also on the screen, for readers who cannot rely on color. Windows high contrast mode always tells the series apart by dash pattern. The value is saved with the form or report.

Read/write.

Code example

None

Inheritance

Declared by WklGauge.

Click event

Signature

Event Click(ByVal Key As String)

Summary

Occurs when the user clicks the gauge.

Parameters

NameTypeOptionalDefaultDescription
KeyStringNo–The value of Key, so one procedure can serve several gauges.

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 WklGauge.

RangeChange event

Signature

Event RangeChange(ByVal OldRange As Long, ByVal NewRange As Long)

Summary

Occurs when the value moves into another range.

Parameters

NameTypeOptionalDefaultDescription
OldRangeLongNo–The position of the range before (from 0 in the order of AddRange), or -1 for none.
NewRangeLongNo–The position of the range now, or -1 for none.

Remarks

In a form module: Private Sub <ControlName>_RangeChange(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklGauge.

en/wiki/msaccess/comctl/api-reference/wklgauge.txt · Last modified: by Wolfgang van der Stille