Color scheme: Light
You are here: start » en » Documentation » Microsoft Access development tools » WKL Forms Object Library » WKL Forms Object Library how-to guides » How to: Show counts on navigation entries

How to: Show counts on navigation entries

Show how many open sessions, unread messages, or failed jobs are waiting behind an entry in a WklNavBar, and keep the number up to date.

Requires WKL Forms Object Library 1.24 or later.

Solution overview

SetBadge Key, Count, Kind, Dot puts a badge on an entry: the count (shown as “99+” above 99), colored by a status kind, or a dot without a number. Badges are run-time values and are never saved with the form, so the application sets them when the form opens and whenever the counts change; for counts that change elsewhere, use Form_Timer.

Implementation

Private Sub Form_Load()
    RefreshBadges
    Me.TimerInterval = 30000          ' every 30 seconds
End Sub
 
Private Sub Form_Timer()
    RefreshBadges
End Sub
 
Private Sub RefreshBadges()
    Dim failed As Long
    failed = DCount("*", "tblJobs", "Status = 'Failed'")
    With Me!navMain.Object
        .SetBadge "sessions", DCount("*", "tblSessions", "IsOpen = True"), wskWarn
        .SetBadge "jobs", failed, IIf(failed > 0, wskBad, wskNeutral)
        .SetBadge "news", 0, wskInfo, DCount("*", "tblNews", "IsRead = False") > 0   ' a dot for "new"
    End With
End Sub

Remarks

  • A count of 0 or less removes the badge, unless Dot is True.
  • Setting a badge doesn't raise an event or change the selection.
  • Screen readers announce the badge along with the entry, for example “Sessions: 3 (Warning)”; the kinds wskWarn and wskBad are named, and a dot is read as “new.”
  • In the icon column, the badge sits at the upper right of the symbol, so a collapsed bar still shows that something is waiting.
en/wiki/msaccess/comctl/how-to/show-counts-on-navigation-entries.txt · Last modified: by Wolfgang van der Stille