Farbschema: Riviera
Sie befinden sich hier: start » en » Documentation » Microsoft Access development tools » WKL Forms Object Library » WKL Forms Object Library API reference » WklToast

WklToast

WklToast class

Signature

Dim myWklToast As New WklToast

Summary

Shows short notes after an action („3 rules deleted – Undo“) at the bottom right of the Access window, as Outlook and Teams do: they never take the focus, close by themselves and can offer one action.

Parameters

None

Remarks

WklToast is an object, not a control: create it with New in any module, also in the module of a subform. A note does not belong to the form that showed it: it stays when that form closes, unless it was shown in that form (Form). Close, CloseAll and Count see the notes of every WklToast object of the Access session; the events Action and Closed go to the object that showed the note.

Placement: without Form, the notes stand in the bottom-right corner of the Access work area, above the status bar; with Form, in the corner of that form (a subform gives the subform's area). At most three are visible, the newest at the bottom; further notes wait and appear when one closes. A note follows its window when it moves or changes size, hides while Access is minimized or the form hidden, and closes when its form closes (wtrOwnerClosed).

Time: 4 seconds, 8 seconds with an action (time to reach it with the keyboard), or DurationMs; 0 keeps the note until the user or code closes it. The time stops while the mouse is over the note or the note has the focus, and a waiting note's time starts only when it appears.

No focus: a note appears without taking the focus or the keyboard, and clicking its action or its close button leaves the focus where it was, for example in a grid. A screen reader announces the note once when it appears, with the key of its action.

Keyboard, only while a note is visible:

  • Ctrl+Shift+Z runs the action of the newest note that has one (Ctrl+Z stays the Undo of Access).
  • F6 moves the focus into the newest note, as F6 reaches the message bar in Office. In the note, Tab moves between the action and the close button, Enter or Space presses the focused one, Esc closes the note, and F6 goes back to where the focus was. From then on F6 moves between the areas of the form (and of a WklDockLayout) as without a note, until another note appears. Shift+F6 never enters a note.

Without any visible note the object installs no keyboard hook and F6 is unchanged.

The action: Action occurs, then ActionFunction is evaluated, then the note closes. Events reach VBA only through a WithEvents variable, which VBA allows in the module of a form, a report or a class, on module level. A procedure that declares the object locally and ends does not hear Action any more; for that case ActionFunction names a function as OnAction of an Access menu does (=WiederHerstellen(17)), which Access evaluates when the user chooses the action, whatever became of the object. An error in that expression is shown in a message box, as Access shows it for a menu entry. ActionFunction needs Access; in other hosts only the event runs.

A walkthrough with Undo after deleting: How to: Show a note after an action, with Undo.

Created with New WklToast or CreateObject.

MemberKindSummary
`Show`MethodShows a note, or queues it when three are visible.
`Close`MethodCloses a note, visible or waiting.
`CloseAll`MethodCloses every note of the Access session, of every WklToast object; Closed occurs for each with wtrCode.
`Count`PropertyGets the number of notes of the Access session, visible and waiting.
`IsOpen`MethodTells whether a note is still visible or waiting.
`ColorScheme`PropertyGets or sets the color scheme of the notes this object shows.
EventSummary
`Action`Occurs when the user chooses the action of a note: a click on the link, Enter or Space on it, Ctrl+Shift+Z, or Invoke by a screen reader.
`Closed`Occurs when a note has closed.

Code example

' In the module of the form frmRules
Private WithEvents mToast As WklToast
 
Private Sub Form_Load()
    Set mToast = New WklToast
End Sub
 
Private Sub cmdDelete_Click()
    Dim id As Long
    id = Me!ID
    CurrentDb.Execute "UPDATE tblRules SET IsDeleted = True WHERE ID = " & id, dbFailOnError
    Me.Requery
    mToast.Show "Rule deleted.", wtkSuccess, , "Undo", id
End Sub
 
Private Sub mToast_Action(ByVal Id As Long, ByVal Tag As Variant)
    CurrentDb.Execute "UPDATE tblRules SET IsDeleted = False WHERE ID = " & Tag, dbFailOnError
    Me.Requery
End Sub

Inheritance

None

Show method

Signature

Function Show(ByVal Text As String, Optional ByVal Kind As WklToastKind = wtkInfo, Optional ByVal Title As String = "", Optional ByVal ActionCaption As String = "", Optional ByVal Tag As Variant, Optional ByVal DurationMs As Long = -1, Optional ByVal Form As Variant, Optional ByVal ActionFunction As String = "") As Long

Summary

Shows a note, or queues it when three are visible.

Parameters

NameTypeOptionalDefaultDescription
TextStringNo–The message, one or a few lines; it wraps. An empty text raises wkeInvalidValue.
Kind`WklToastKind`YeswtkInfoColor and symbol, a WklToastKind; wtkInfo (default). A value outside the enumeration raises wkeInvalidValue.
TitleStringYes""A bold first line; empty (default) for none.
ActionCaptionStringYes""The caption of the action link, for example Undo; empty (default) for a note without action.
TagVariantYes–Any value that Action passes back, for example the key of the deleted record; the note keeps its own copy.
DurationMsLongYes-1How long the note stays, in milliseconds; -1 (default) for 4 seconds, or 8 seconds with an action; 0 keeps it until it is closed.
FormVariantYes–The form the note appears in (Me, or a subform's Form), or a window handle; omitted for the work area of Access. A window of another application raises wkeInvalidValue.
ActionFunctionStringYes""An expression Access evaluates when the user chooses the action, with or without a leading =, for example =WiederHerstellen(17); empty (default) for none.

Return value: Long – The id of the note, unique in the Access session; Close and the events use it.

Remarks

Without Form, the note needs an Access window (or in other hosts an active window); when there is none, Show raises wkeNotAvailable.

Code example

None

Inheritance

Declared by WklToast.

Close method

Signature

Sub Close(ByVal Id As Long)

Summary

Closes a note, visible or waiting.

Parameters

NameTypeOptionalDefaultDescription
IdLongNo–The id Show returned; an id that is closed or unknown does nothing.

Remarks

Closed occurs with wtrCode. A waiting note that is closed never appears.

Code example

None

Inheritance

Declared by WklToast.

CloseAll method

Signature

Sub CloseAll()

Summary

Closes every note of the Access session, of every WklToast object; Closed occurs for each with wtrCode.

Parameters

None

Remarks

None

Code example

None

Inheritance

Declared by WklToast.

Count property

Signature

Property Get Count() As Long

Summary

Gets the number of notes of the Access session, visible and waiting.

Parameters

None

Property value: Long – 0 when no note is open.

Remarks

Read-only.

Code example

None

Inheritance

Declared by WklToast.

IsOpen method

Signature

Function IsOpen(ByVal Id As Long) As Boolean

Summary

Tells whether a note is still visible or waiting.

Parameters

NameTypeOptionalDefaultDescription
IdLongNo–The id Show returned.

Return value: Boolean – True while the note is visible or waits; False after it closed.

Remarks

None

Code example

None

Inheritance

Declared by WklToast.

ColorScheme property

Signature

Property Get ColorScheme() As WklColorScheme
Property Let ColorScheme(RHS As WklColorScheme)

Summary

Gets or sets the color scheme of the notes this object shows.

Parameters

None

Property value: `WklColorScheme` – wcoAutomatic (default), wcoLight, wcoDark or wcoHighContrast.

Remarks

The scheme applies to notes shown after the change; a note already on the screen keeps its colors. It colors background, text, action link, border, and the bar and symbol in the color of the kind. wcoAutomatic follows, in this order, Windows high contrast mode, then the color set of the database design of the Access the code runs in (Access: Design › Themes or Colors, read once per Show), and draws light when the database has no design or the code runs in Excel or Word. Office's own design setting and the Windows app mode are not followed. In high contrast mode the notes always use the system colors. Every text keeps a contrast of at least 4.5:1. The setting is not stored: WklToast is an object in VBA, so set it after New WklToast when the notes should not follow the database.

Read/write.

Code example

None

Inheritance

Declared by WklToast.

Action event

Signature

Event Action(ByVal Id As Long, ByVal Tag As Variant)

Summary

Occurs when the user chooses the action of a note: a click on the link, Enter or Space on it, Ctrl+Shift+Z, or Invoke by a screen reader.

Parameters

NameTypeOptionalDefaultDescription
IdLongNo–The id of the note.
TagVariantNo–The Tag given to Show.

Remarks

The note closes after the event (Closed with wtrAction), also when the procedure raises an error. ActionFunction runs after the event.

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

Code example

None

Inheritance

Declared by WklToast.

Closed event

Signature

Event Closed(ByVal Id As Long, ByVal Reason As WklToastCloseReason)

Summary

Occurs when a note has closed.

Parameters

NameTypeOptionalDefaultDescription
IdLongNo–The id of the note.
Reason`WklToastCloseReason`No–Why it closed, a WklToastCloseReason.

Remarks

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

Code example

None

Inheritance

Declared by WklToast.

en/wiki/msaccess/comctl/api-reference/wkltoast.txt · Zuletzt geändert: von Wolfgang van der Stille