Article ID: 132138
Article Last Modified on 11/6/2000
Option Explicit
Dim MyVal As Long, MyValSort As Long
' ******************************************************
' Function: SetGroupLevel
'
' Purpose: This function creates groups of records
' containing n records. The n is defined
' by the Const MyIncNum statement.
' ******************************************************
Function SetGroupLevel (pId As Variant) As Integer
' Set the value for the number of records to group.
Const MyIncNum = 100
' Compare the value of MyVal to the custom value
' and if true, increment the group value by one.
If MyVal = MyIncNum Then
MyValSort = MyValSort + 1
MyVal = False
End If
' Continue to increment counter.
MyVal = MyVal + 1
' Pass back the custom group value to query.
SetGroupLevel = MyValSort
End Function
' ******************************************************
' Function: SetGroupLevelReset
'
' Purpose: This function is called to reset the counter
' values used in the SetGroupLevel() function.
' ******************************************************
Function SetGroupLevelReset () As Integer
MyVal = False
MyValSort = False
End Function
Query: TestGroupLevel
---------------------
Type: Totals Query
Field: Quantity
Table: Order Details
Total: Sum
Field: MyGroup: SetGroupLevel([Quantity])
Total: Group By
Macro Name Actions
-------------------------------
TestGroupLevelMacro RunCode
OpenQuery
TestGroupLevelMacro Actions
--------------------------------------
RunCode
Function Name: SetGroupLevelReset()
OpenQuery
Query Name: TestGroupLevel
Data Mode: Add
SumOfQuantity MyGroup
----------------------
2187 0
2248 1
2175 2
2262 3
1799 4
2307 5
2363 6
Keywords: kbhowto kbusage KB132138