Color scheme: Dark
You are here: start » en » Documentation » Microsoft Access development tools » WKL Forms Object Library » WKL Forms Object Library how-to guides » How to: Build a start page with key figures

How to: Build a start page with key figures

Show what needs attention on the first page of an application (figures with a status, a gauge for a load), and open the matching list with one click.

Requires WKL Forms Object Library 1.44 or later.

Solution overview

  • One WklKpiCard per figure that may need action. StatusText and StatusKind show whether it does; Compare and DeltaKind show the change since the last refresh.
  • A WklGauge for a load against limits, with ranges for ok, warn, and bad.
  • A timer refreshes the values (Form_Timer); nothing is bound, so the page works with any data source, including a linked OData table.
  • Click(Key) opens the list. Every card has a Key; one procedure opens the list with the filter for that key.

Implementation

The form frmStart with the cards kpiLocked and kpiExpiring and the gauge gauLoad (insert them from the controls gallery or with the Insert ActiveX Control dialog box), TimerInterval 5000:

Private Sub Form_Load()
    With Me!kpiLocked.Object
        .Title = "Locked accounts"
        .Key = "locked"
        .Clickable = True
        .StatusKind = wskBad
    End With
    With Me!kpiExpiring.Object
        .Title = "Expiring within 30 days"
        .Key = "expiring"
        .Clickable = True
        .StatusKind = wskWarn
    End With
    With Me!gauLoad.Object
        .Caption = "Sign-ins per minute"
        .Max = 200
        .AddRange 0, 120, wskOk
        .AddRange 120, 170, wskWarn
        .AddRange 170, 200, wskBad
    End With
    Form_Timer
End Sub
 
Private Sub Form_Timer()
    ShowCount Me!kpiLocked.Object, DCount("*", "tblPeople", "Status = 'Locked'"), "Action needed"
    ShowCount Me!kpiExpiring.Object, DCount("*", "tblPeople", "Expires Between Date() And Date() + 30"), "Notice"
    Me!gauLoad.Object.Value = DLookup("PerMinute", "qryLogonRate")
End Sub
 
Private Sub ShowCount(ByVal card As Object, ByVal count As Long, ByVal needsAction As String)
    card.Compare = card.Value
    card.Value = count
    card.StatusText = IIf(count > 0, needsAction, "")
    card.AddPoint count
End Sub
 
Private Sub kpiLocked_Click(ByVal Key As String)
    OpenList Key
End Sub
 
Private Sub kpiExpiring_Click(ByVal Key As String)
    OpenList Key
End Sub
 
Private Sub OpenList(ByVal key As String)
    Select Case key
        Case "locked": DoCmd.OpenForm "frmPeople", , , "Status = 'Locked'"
        Case "expiring": DoCmd.OpenForm "frmPeople", , , "Expires Between Date() And Date() + 30"
    End Select
End Sub

Remarks

  • The first refresh has no comparison value (Compare is Null until the second one), so no change is shown yet.
  • The sparkline needs room below the value; on a short card, it's left out.
  • In a shell with a WklNavBar, open the list as the page of the subform instead of a window: set SourceObject of the page subform and the bar's SelectedKey, and pass the filter to the page in a module variable that its Form_Load reads. The WKL Administration Shell Template works this way.
en/wiki/msaccess/comctl/how-to/build-a-start-page-with-key-figures.txt · Last modified: by Wolfgang van der Stille