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
WklKpiCardper figure that may need action.StatusTextandStatusKindshow whether it does;CompareandDeltaKindshow the change since the last refresh. - A
WklGaugefor 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 aKey; 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 (
Compareis 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: setSourceObjectof the page subform and the bar'sSelectedKey, and pass the filter to the page in a module variable that itsForm_Loadreads. The WKL Administration Shell Template works this way.
Related topics
en/wiki/msaccess/comctl/how-to/build-a-start-page-with-key-figures.txt · Last modified: by Wolfgang van der Stille