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

WklActionBar

WklActionBar class

Signature

Dim myWklActionBar As WklActionBar
Set myWklActionBar = Me!ControlName.Object

Summary

The header of a page or an application shell: a band with title, subtitle and status, and below it a command row with a primary command, split buttons, a More menu and a group at the right edge.

Parameters

None

Remarks

One bar serves a whole shell. Place it above the subform that shows the pages and let the shell set the commands of the page it shows - in one assignment as JSON (Commands) or one by one (AddCommand). Every choice arrives in one event, CommandClick(Key): a click, an entry of a menu, the menu of a split button, an access key, a shortcut, or Invoke by a screen reader.

The bar measures its buttons itself. When the row is too narrow, commands leave it from the end and appear at the end of the More menu; the primary command leaves last, and the right group (wcpRight, for example Export and Refresh) always stays. Commands with wcpMenu are always in More. A command with children (Parent of other commands) is a split button: its main part runs the command, its arrow opens the children.

An & in a caption marks the access key; Alt and the letter run the command, or open More - from any control of the form. A letter the bar does not use goes on to Access. A command's Shortcut works anywhere in the form, subforms included, while the form is shown; list each combination in one place only - in the bar or in WklDockLayout.ShortcutKeys. Shortcuts are not watched on Excel and Word UserForms.

Commands set in design view are stored with the form. Set in form view, they are not a change of the form, so a shell that fills the bar per page does not ask to be saved. CommandClick runs after the click, key or menu has been handled, so the procedure may show a message box or change the page.

The band takes BackColor and ForeColor; the command row keeps the window color, so the buttons stay readable on a dark band. In high contrast mode the bar uses the system colors. Screen readers hear a toolbar named by the title, with a button per command.

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
`Caption`PropertyGets or sets the title in the band.
`Subtitle`PropertyGets or sets the line under the title.
`BackColor`PropertyGets or sets the color of the band.
`ForeColor`PropertyGets or sets the color of the title, and of the subtitle while SubtitleForeColor is -1.
`Commands`PropertyGets or sets all commands as JSON text.
`AddCommand`MethodAdds a command.
`RemoveCommand`MethodRemoves a command together with its children.
`ClearCommands`MethodRemoves all commands.
`CommandEnabled`PropertyGets or sets whether a command can be run.
`CommandVisible`PropertyGets or sets whether a command is shown.
`CommandCaption`PropertyGets or sets the caption of a command.
`CommandCount`PropertyGets the number of commands, children included.
`CommandKey`PropertyGets the key of the command at a position.
`MoreCaption`PropertyGets or sets the caption of the More button.
`MoreGlyph`PropertyGets or sets the glyph of the More button.
`StatusText`PropertyGets or sets the text of the status pill at the top right of the band.
`StatusKind`PropertyGets or sets the kind of the status, which sets the colors of the pill.
`StatusCount`PropertyGets or sets a count shown beside the status pill.
`CommandTooltip`PropertyGets or sets the tooltip of a command.
`ColorScheme`PropertyGets or sets the color scheme the control draws in.
`Logo`PropertyGets or sets the picture at the left of the band, for example the logo of the application.
`SubtitleForeColor`PropertyGets or sets the color of the subtitle.
EventSummary
`CommandClick`Occurs when the user chooses a command: a click on its button, an entry of a menu, the main part of a split button, its access key, its shortcut, or Invoke by a screen reader.

Code example

Private Sub ShowPage(ByVal page As String)
    Me!sfPage.SourceObject = page
    With Me!barShell.Object
        .Caption = Me!sfPage.Form.Caption
        .Subtitle = Nz(Me!sfPage.Form.Tag, "")
        .ClearCommands
        .AddCommand "neu", "&Neu", "E710", wcpStandard, "^N"
        .AddCommand "bearbeiten", "Bearbei&ten", "E70F"
        .AddCommand "issue", "&Issue key ...", "E8D7", wcpPrimary
        .AddCommand "lock", "&Lock key ...", "", wcpMenu
        .AddCommand "export", "E&xportieren ...", "EDE1", wcpRight
        .AddCommand "refresh", "&Aktualisieren", "E72C", wcpRight, "{F5}"
    End With
End Sub
 
Private Sub barShell_CommandClick(ByVal Key As String)
    RunAreaCommand Key
End Sub

Inheritance

None

Caption property

Signature

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

Summary

Gets or sets the title in the band.

Parameters

None

Property value: String – The title; empty (default) shows the caption of the form the bar stands on.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklActionBar.

Subtitle property

Signature

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

Summary

Gets or sets the line under the title.

Parameters

None

Property value: String – The text; empty (default) for none.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklActionBar.

BackColor property

Signature

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

Summary

Gets or sets the color of the band.

Parameters

None

Property value: OLE_COLOR – An OLE color; default the window background. The command row below keeps the window color.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklActionBar.

ForeColor property

Signature

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

Summary

Gets or sets the color of the title, and of the subtitle while SubtitleForeColor is -1.

Parameters

None

Property value: OLE_COLOR – An OLE color; default the window text color. Choose it with enough contrast to BackColor.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklActionBar.

Commands property

Signature

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

Summary

Gets or sets all commands as JSON text.

Parameters

None

Property value: String – A JSON array of objects, one per command, in order: key and caption are required; glyph, placement (standard, primary, menu, right), shortcut, parent, tooltip, beginGroup, enabled, visible are optional. Empty for none.

Remarks

Setting the text replaces the whole set, so a shell can keep one text per page. A text with an error - invalid JSON, a name the bar does not know, an entry that breaks a rule of AddCommand - raises wkeInvalidValue (or wkeDuplicateKey) naming the entry (“Befehl 3: …”), and the commands stay as they were.

Read/write.

Code example

Me!barShell.Object.Commands = "[{""key"":""neu"",""caption"":""&Neu"",""glyph"":""E710"",""shortcut"":""^N""}," & _
    "{""key"":""refresh"",""caption"":""&Aktualisieren"",""glyph"":""E72C"",""placement"":""right""}]"

Inheritance

Declared by WklActionBar.

AddCommand method

Signature

Sub AddCommand(ByVal Key As String, ByVal Caption As String, Optional ByVal Glyph As String = "", Optional ByVal Placement As WklCommandPlacement = wcpStandard, Optional ByVal Shortcut As String = "", Optional ByVal Parent As String = "", Optional ByVal Tooltip As String = "", Optional ByVal BeginGroup As Boolean = False)

Summary

Adds a command.

Parameters

NameTypeOptionalDefaultDescription
KeyStringNo–The key CommandClick reports; unique, case is ignored. A key used twice raises wkeDuplicateKey.
CaptionStringNo–The text; an & marks the access key, && is a literal &. Required.
GlyphStringYes""A code of Segoe Fluent Icons, for example E710; empty for none.
Placement`WklCommandPlacement`YeswcpStandardA WklCommandPlacement; wcpStandard by default. Ignored for a command with Parent.
ShortcutStringYes""A key combination in SendKeys notation, for example ^N or {F5}; empty for none. A letter or digit without Ctrl (^) or Alt (%) is refused, and so is a combination another command has.
ParentStringYes""The key of a command added before, whose menu takes this one: a command in the row becomes a split button, a menu command gets a submenu. One level only; a command at the right edge has no menu.
TooltipStringYes""The tooltip; empty shows the caption and the shortcut.
BeginGroupBooleanYesFalseTrue draws a separator line before the command, in the row and in menus.

Remarks

None

Code example

None

Inheritance

Declared by WklActionBar.

RemoveCommand method

Signature

Sub RemoveCommand(ByVal Key As String)

Summary

Removes a command together with its children.

Parameters

NameTypeOptionalDefaultDescription
KeyStringNo–The key. A key without a command raises wkeKeyNotFound.

Remarks

None

Code example

None

Inheritance

Declared by WklActionBar.

ClearCommands method

Signature

Sub ClearCommands()

Summary

Removes all commands.

Parameters

None

Remarks

None

Code example

None

Inheritance

Declared by WklActionBar.

CommandEnabled property

Signature

Property Get CommandEnabled(ByVal Key As String) As Boolean
Property Let CommandEnabled(ByVal Key As String, RHS As Boolean)

Summary

Gets or sets whether a command can be run.

Parameters

NameTypeOptionalDefaultDescription
KeyStringNo–The key of the command, also of one in a menu. A key without a command raises wkeKeyNotFound.

Property value: Boolean – True (default) or False. A disabled command is drawn gray; its click, access key and shortcut do nothing.

Remarks

Set it from the state of the record, for example .CommandEnabled("sperren") = Me!lstPersons.Object.CanDelete. The children of a disabled command cannot run either.

Read/write.

Code example

None

Inheritance

Declared by WklActionBar.

CommandVisible property

Signature

Property Get CommandVisible(ByVal Key As String) As Boolean
Property Let CommandVisible(ByVal Key As String, RHS As Boolean)

Summary

Gets or sets whether a command is shown.

Parameters

NameTypeOptionalDefaultDescription
KeyStringNo–The key of the command. A key without a command raises wkeKeyNotFound.

Property value: Boolean – True (default) or False. A hidden command takes no place and its shortcut is not watched.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklActionBar.

CommandCaption property

Signature

Property Get CommandCaption(ByVal Key As String) As String
Property Let CommandCaption(ByVal Key As String, RHS As String)

Summary

Gets or sets the caption of a command.

Parameters

NameTypeOptionalDefaultDescription
KeyStringNo–The key of the command. A key without a command raises wkeKeyNotFound.

Property value: String – The text; an & marks the access key. An empty text raises wkeInvalidValue.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklActionBar.

CommandCount property

Signature

Property Get CommandCount() As Long

Summary

Gets the number of commands, children included.

Parameters

None

Property value: Long – 0 without commands.

Remarks

Read-only.

Code example

None

Inheritance

Declared by WklActionBar.

CommandKey property

Signature

Property Get CommandKey(ByVal Index As Long) As String

Summary

Gets the key of the command at a position.

Parameters

NameTypeOptionalDefaultDescription
IndexLongNo–The position, 0 for the first command, in the order they were added. A position outside 0 to CommandCount - 1 raises wkeKeyNotFound.

Property value: String – The key.

Remarks

Read-only.

Code example

None

Inheritance

Declared by WklActionBar.

MoreCaption property

Signature

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

Summary

Gets or sets the caption of the More button.

Parameters

None

Property value: String – The text; an & marks the access key. Default: More in the language of the components (&More, &Weitere, &Več, &Više, &Altro). An empty text raises wkeInvalidValue.

Remarks

A bar that holds the default of any of these languages, for example &Weitere saved in a German session, counts as holding the default: it shows More in the language the components use at run time. A caption key such as @orders.more shows the application text of that key in the language of the session (see WklTexts); any other text is shown as it is.

Read/write.

Code example

None

Inheritance

Declared by WklActionBar.

MoreGlyph property

Signature

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

Summary

Gets or sets the glyph of the More button.

Parameters

None

Property value: String – A code of Segoe Fluent Icons, default E712; empty for none. An invalid code raises wkeInvalidValue.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklActionBar.

StatusText property

Signature

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

Summary

Gets or sets the text of the status pill at the top right of the band.

Parameters

None

Property value: String – The text, for example “Verbunden” or “aktualisiert 12:51”; empty (default) for none.

Remarks

A change in form view is announced to screen readers.

Read/write.

Code example

None

Inheritance

Declared by WklActionBar.

StatusKind property

Signature

Property Get StatusKind() As WklStatusKind
Property Let StatusKind(RHS As WklStatusKind)

Summary

Gets or sets the kind of the status, which sets the colors of the pill.

Parameters

None

Property value: `WklStatusKind` – A WklStatusKind; wskNeutral by default. Other values raise wkeInvalidValue.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklActionBar.

StatusCount property

Signature

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

Summary

Gets or sets a count shown beside the status pill.

Parameters

None

Property value: Long – 0 (default) for none; above 99 the badge shows 99+. A negative value raises wkeInvalidValue.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklActionBar.

CommandTooltip property

Signature

Property Get CommandTooltip(ByVal Key As String) As String
Property Let CommandTooltip(ByVal Key As String, RHS As String)

Summary

Gets or sets the tooltip of a command.

Parameters

NameTypeOptionalDefaultDescription
KeyStringNo–The key of the command. A key without a command raises wkeKeyNotFound.

Property value: String – The text; empty shows the caption and the shortcut (“New (Ctrl+N)”). Screen readers hear it as help text.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklActionBar.

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 band and the command row while BackColor and ForeColor keep their defaults (a band color you set, such as the navy of a shell, wins), the lines, the status pill background, the command buttons as WklButton draws them and the menus; 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 WklActionBar.

Logo property

Signature

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

Summary

Gets or sets the picture at the left of the band, for example the logo of the application.

Parameters

None

Property value: String – A file (absolute, or relative to the folder of the database), the name of a shared image of the database, SVG text starting with <, or a data URI - the sources of WklImage.Source; empty (default) for no logo.

Remarks

The logo is drawn at the height of the band less 8 pixels at the top and bottom, in its own proportions; title and subtitle move to the right of it and keep their height. A URL raises wkeInvalidValue at the assignment. A source that cannot be read (a missing file, an unknown image name) raises no error: the band is drawn without a logo. Outside Access (UserForms) a relative path is relative to the current folder of the process, and shared images are not available. The value is saved with the form.

Read/write.

Code example

Me!barShell.Object.Logo = "Firmenlogo"   ' a shared image of the database

Inheritance

Declared by WklActionBar.

SubtitleForeColor property

Signature

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

Summary

Gets or sets the color of the subtitle.

Parameters

None

Property value: Long – A color number as RGB() returns it (a system color such as &H80000008 is accepted too); -1 (default) for the color of the title (ForeColor). The type is Long, not OLE_COLOR, so that -1 can be assigned; the property sheet therefore offers no color builder for it, the designer does.

Remarks

Available from release 1.59. With -1 the subtitle is drawn in the color of the title, as before 1.59; forms saved with an older release open with -1. Any other value is drawn as given, like ForeColor: choose a color with a contrast of at least 4.5:1 to the band (BackColor). In Windows high contrast, title and subtitle take the system's text color. The value is saved with the form. In the designer the card “Subtitle color” offers it, with the switch “Same as the title” for -1.

Read/write.

Code example

With Me!barShell.Object
    .ForeColor = vbWhite
    .SubtitleForeColor = RGB(212, 175, 55)   ' gold under a white title on a navy band
End With

Inheritance

Declared by WklActionBar.

CommandClick event

Signature

Event CommandClick(ByVal Key As String)

Summary

Occurs when the user chooses a command: a click on its button, an entry of a menu, the main part of a split button, its access key, its shortcut, or Invoke by a screen reader.

Parameters

NameTypeOptionalDefaultDescription
KeyStringNo–The key of the command.

Remarks

A disabled or hidden command raises nothing. A command that only opens a menu (a menu command with children) raises nothing either; its children do.

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

Code example

None

Inheritance

Declared by WklActionBar.

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