WklToggleSwitch
WklToggleSwitch displays a Yes/No field as a switch that takes effect immediately, like the
switches in Windows Settings. You bind it just like a check box, and the same switch is available as
a column type in WklGrid and WklTreeList (wedToggle).
Get started
Common tasks
Visual aid
+- frmUser: Form View -------------------------------------------------+ | Name [ Miller ] | | Account ( o==) Active 1 2 3 | | Email (==o ) Off | +----------------------------------------------------------------------+
| Region | Meaning |
|---|---|
| 1 | The caption (Caption), which is also the name a screen reader announces |
| 2 | The switch, bound to a Yes/No field; click it or press Space to toggle it |
| 3 | The state text (OnText / OffText; “On” / “Off” by default) |
Key features
- Binds like a check box through the Control Source property, to a Yes/No field or a bit column in a linked SQL Server table; for Null, the switch is gray with the knob in the middle.
- Toggling the switch is an edit: Access is asked first (and refuses if
Lockedis set or the form doesn't allow edits), the record becomes dirty, andChangefires. SettingMe.Dirty = FalseinChangesaves the record immediately; Undo returns the switch to its previous position. - Custom caption and state texts (“Active” / “Locked”), colors, and font; the designer's Switch page shows both states.
- Keyboard and screen reader support: Space toggles the switch; screen readers announce a button with the Toggle pattern, plus the state text.
- The same switch in lists (
wedToggle), toggled with a click or Space and saved like any other cell edit.
Core concepts
Access does the binding. Access writes the field to Value whenever the record changes, and the
switch reports the user's change back through Access, so Access stays in charge of editing, Undo,
and saving. Setting Value in code only changes what the switch displays; to change the field in
code, change the field.
In Change, read the switch, not the field. Access writes the field no later than when the
record is saved, so in Change the field may still hold the old value.
Where you can use it. Single forms, form headers and footers, and UserForms (unbound). It can't
go in the detail section of a continuous form; use a wedToggle column in WklGrid there.
Administration
Troubleshooting
For developers
Related topics
None