Hello Peter
You will need to add a Command Button to your form and then put the Following code in the "On Element Entry" event. You will need to replace "MyForm" in four places with the name of your form. You will also need to replace "GroupNumber" in three places with the name of the Field that contains the Unique Number for each group. As long as the Group field is named "GROUP" then you will not need to change anything else.
In order for this report to work correctly the records need to be sorted either by Group or by the Unique Group Number. If you have any more questions about the code do not hesitate to ask.
Var vGroup as int
Var vRecord as int
Var vRecordTotal as int
Var vPosition as int
Var vCount as int
Var vTotal as int
Var vGroupName as String
Var vSuccess as int
vRecordTotal = @FormResultSetTotal("MyForm")
If vRecordTotal > 0 Then
{
vRecord = 1
vGroup = -1
vPosition = @FormResultSetCurrentPosition("MyForm")
NewPage(850,1100)
PrintString("Number of Campers in Each Group", 50, 35, 0, "Arial", 20, 0)
PrintString(" ", 50, 60, 0, "", 0, 0)
While vRecord <= vRecordTotal
{
FormResultSetCurrentPosition("MyForm", vRecord)
If vRecord = 1 Then
{
vGroup = GroupNumber
vGroupName = GROUP
}
If vGroup = GroupNumber Then
{
//Same Group
vCount = vCount + 1
}
Else
{
//New Group
PrintString(vGroupName, 50, @PageExtentY() + 2, 125, "Arial", 15, 0)
Printstring(vCount, -1, -1, 0, "Arial", 15, 0)
vGroupName = GROUP
vTotal = vTotal + vCount
vGroup = GroupNumber
vCount = 1
}
vRecord = vRecord + 1
}
PrintString(GROUP, 50, @PageExtentY() + 2, 125, "Arial", 15, 0)
PrintString(vCount, -1, -1, 0, "Arial", 15, 0)
vTotal = vTotal + vCount
PrintString("Total Number of Campers " + VTotal, 50, @PageExtentY() + 20, 0, "Arial", 20, 0)
FinishPage()
//Returns user to the record they were on
FormResultSetCurrentPosition("MyForm", vPosition)
}
Note: If any lines are wrapped they will need to be unwrapped in the Program Editor.