Report.
You can use the GroupLevel property in Visual Basic to refer to the group level you are grouping or sorting on.
The GroupLevel property setting is an array in which each entry identifies a group level. To refer to a group level, use this syntax:
GroupLevel(n)
The number n is the group level, starting with 0. The first field or expression you group on is group level 0, the second is group level 1, and so on. You can have up to 10 group levels (0 to 9).
The following sample settings show how you use the GroupLevel property to refer to a group level.
Group Level |
Refers to |
GroupLevel(0) |
The first field or expression you sort or group on. |
GroupLevel(1) |
The second field or expression you sort or group on. |
GroupLevel(2) |
The third field or expression you sort or group on. |
You can use this property in Visual Basic only to set the SortOrder, GroupOn, GroupInterval, KeepTogether, and ControlSource properties. You set these properties in the Open event procedure of a report.
In reports, you can group or sort on more than one field or expression. Each field or expression you group or sort on is a group level.
You specify the fields and expressions to sort and group on using the CreateGroupLevel function.
If group level 0 is already defined for a report, you can use the ControlSource property to reset the group level during the report’s Open event procedure. For example, during the Open event procedure of a report, you can display a dialog box called SortForm that prompts you to enter the field to sort on. If you enter a name into a text box (txtPromptYou) in the dialog box, you can set the property to the contents of the text box.
Dim strGetSortField As String= Forms![SortForm]![txtPromptYou].GroupLevel(0).ControlSource = strGetSortField
CreateGroupLevel Function, GroupInterval Property, GroupOn Property, KeepTogether Property — Groups, SortOrder Property.
See the GroupInterval property example.