Using the Form Designer, you can create a dashboard to show graphs and list key figures for your company. This tutorial requires the AR and IN Modules.
This tutorial will show you how to display Monthly Sales on a form.
No. |
Name |
Display Label |
Type |
Domain |
Size |
Width |
Req |
Visible |
1 |
PeriodID |
PeriodID |
Byte |
|
|
10 |
|
Clear |
2 |
ExclusiveAmount |
Amount |
Float |
Amount |
|
10 |
|
Selected |
3 |
PeriodName |
Period |
String |
|
16 |
15 |
|
Selected |
No. |
Name |
Unique |
Primary |
Parts |
1 |
Period |
|
Selected |
+PeriodID |
Property |
Value |
Description |
Anchors |
[akLeft] |
Click the Expand [x] button next to Anchors, and set akTop to False. This will bind the graph to the left. |
BackWallColor |
clWhite |
Click the [...] button in BackWallColor, and click white, to set the graph back wall to white. |
Height |
258 |
Sets the graph height. You can also drag to change the height. |
Left |
0 |
Moves the graph to the left of the form. |
ShowGridLines |
False |
Hides the grid lines. |
ShowLegend |
False |
Hides the legend. |
Top |
52 |
Sets the graph position from the top. You can also drag to change the position. |
Width |
640 |
Sets the graph width. You can also drag to change the width. |
Field Name |
Show Key Border |
Pen Style |
Pen Width |
ExclusiveAmount |
Selected |
psClear |
2 |
You can now write the MaxBasic code to populate the Memory Table and graph.
Dim PeriodToUse as Number, StartPeriod as Number, EndPeriod as Number
PeriodToUse = CurrentPeriod("AR")
StartPeriod = AddPeriod(PeriodToUse, -12,True)
EndPeriod = AddPeriod(PeriodToUse, -1,True)
This sets the PeriodToUse to the current AR Period, the StartPeriod to 12 periods prior to the PeriodToUse, and EndPeriod to 1 period before PeriodToUse.
Sub RefreshSales
Dim tblSales as Object 'Will be used to store the query data
Dim TotalSales as Number
tblGrpSales.empty 'Clear the memory table
'Enter the SQL Query to extract the sales amounts per period
SQLSales ="SELECT INHEAD.PeriodID as PeriodID " & _
" ,Sum(INHEAD.ExclusiveAmountBs) as ExclusiveAmount " & _
"FROM INHEAD " & _
"WHERE INHEAD.PeriodID Between :LYStart AND :TYEnd " & _
" AND INHEAD.PostStatus = 'P' " & _
" AND INHEAD.DocumentClass IN ('I', 'C') " & _
"GROUP BY INHEAD.PeriodID " & _
"ORDER BY INHEAD.PeriodID "
tblSales = ExecuteSQL(SQLSales, StartPeriod, EndPeriod)
tblGrpSales.AllowInsertDelete = True
tblGrpSales.IndexName = "Period"
tblSales.First
Do Until tblSales.EOF
tblGrpSales.Append
CopyFieldsByName(tblSales, tblGrpSales)
tblGrpSales.PeriodName = PeriodName(tblSales.PeriodID)
tblGrpSales.Save
tblSales.Next
Loop
tblGrpSales.AllowInsertDelete = False
tblGrpSales.IndexName = "Period"
graphSales.RefreshData
End Sub
Sub OnCreate
RefreshSales
End Sub
Sub OnLinkSales
Dim Report as Object
Report = CreateObject("Accredo.INInvoiceReport")
Report.Layout = "Invoice"
Report.Destination = "Screen"
Report.Type.Invoice = True
Report.Type.Credit = True
Report.Type.Quote = False
Report.PostStatus.Posted = True
Report.PostStatus.Unposted = False
Report.PostStatus.Open = False
Report.PostStatus.Deleted = False
Report.CurrentHistory = "Both Current and History"
Report.Invoices = "Range of Periods"
Report.PeriodFrom = StartPeriod
Report.PeriodTo = EndPeriod
Report.Preferences.IncludeRecordsWithEmptyDetail = False
End Sub
(Ctrl+S).(Ctrl+R) to test the form.