You can filter the Top Customers dashboard form created in the FD Tutorial: Dashboard Top Customers. This tutorial will show you how to limit the number of customers shown.
(Ctrl+O) to open your Top Customers form.Sub RefreshTopCustomers
tblTopCustomers.Empty
if eSPLimit.value < 1 then eSPLimit.value = 5 ' < ADDED
NumTopCustomers = eSPLimit.Value ' < ADDED
SQL = "SELECT INHEAD.CustomerCode " & _
" ,ARCUST.CustomerName " & _
" ,Sum(INHEAD.ExclusiveAmount) as Sales " & _
"FROM ARCUST " & _
" INNER JOIN INHEAD ON ARCUST.CustomerCode=INHEAD.CustomerCode " & _
"WHERE (INHEAD.DocumentClass in ( 'I' , 'C' ) " & _
" AND INHEAD.PostStatus in ( 'U' , 'P' )) " & _
"GROUP BY INHEAD.CustomerCode " & _
" ,ARCUST.CustomerName " & _
"ORDER BY 3 DEsc "
Dim tblTemp as Object
tblTemp = ExecuteSQL(SQL)
tblTemp.First
Count = 1 ' < ADDED
Do Until tblTemp.EOF or (Count > NumTopCustomers) ' < ADDED
tblTopCustomers.Append
tblTopCustomers.CustomerCode = tblTemp.CustomerCode
tblTopCustomers.CustomerName = tblTemp.CustomerName
tblTopCustomers.SalesValue = tblTopCustomers.SalesValue + tblTemp.Sales
tblTopCustomers.Save
Count = Count + 1 ' < ADDED
tblTemp.Next
Loop
graphTopCust.RefreshData
End Sub
If the Spin Edit is 0, we set it to 5 as a default. We have added a field called NumTopCustomers that takes the Limit from the spin edit component. We have also added a Count, to count how many records we have added. The Count gets incremented each time a record is added. We have changed our loop condition to check whether Count is still below the Limit.
(Ctrl+S).(Ctrl+R) to test the form.