Class GroupLevel (Access VBA)
You can use the GroupLevel property in Visual Basic to refer to the group level that you are grouping or sorting on in a report. To use a GroupLevel class variable it first needs to be instantiated, for example
ControlSource
You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression.
The ControlSource property uses the following settings.
Forms!Customers!AddressPart.ControlSource = "City"
GroupFooter
You can use the GroupFooter property to create a group footer for a selected field or expression in a report.
You can use group headers and footers to label or summarize data in a group of records. For example, if you set the GroupHeader property to Yes for the Categories field, each group of products will begin with its category name.
CreateReport.GroupLevel.GroupFooter = True
GroupHeader
You can use the GroupHeader property to create a group header for a selected field or expression in a report.
You can use group headers and footers to label or summarize data in a group of records. For example, if you set the GroupHeader property to Yes for the Categories field, each group of products will begin with its category name.
CreateReport.GroupLevel.GroupHeader = True
GroupInterval
You can use the GroupInterval property with the GroupOn property to specify how records are grouped in a report.
The GroupInterval property specifies an interval value that records are grouped by. This interval differs depending on the data type and GroupOn property setting of the field or expression that you are grouping on. For example, you can set the GroupInterval property to 1 if you want to group records by the first character of a Text field, such as ProductName. The GroupInterval property settings are Long values that depend on the field's data type and its GroupOn property setting. The default GroupInterval setting is 1. You can set the GroupInterval property only in the Open event procedure of a report.
Private Sub Report_Open(Cancel As Integer)
' Set SortOrder property to ascending order.
Me.GroupLevel(0).SortOrder = False
' Set GroupOn property.
Me.GroupLevel(0).GroupOn = 1
' Set GroupInterval property to 1.
Me.GroupLevel(0).GroupInterval = 1
' Set KeepTogether property to With First Detail.
Me.GroupLevel(0).KeepTogether = 2
End Sub
GroupOn
You can use the GroupOn property in a report to specify how to group data in a field or expression by data type. For example, this property lets you group a Date field by month.
The GroupOn property settings available for a field depend on its data type, as the following table shows. For an expression, all the settings are available. The default setting for all data types is Each Value.
Private Sub Report_Open(Cancel As Integer)
' Set SortOrder property to ascending order.
Me.GroupLevel(0).SortOrder = False
' Set GroupOn property.
Me.GroupLevel(0).GroupOn = 1
' Set GroupInterval property to 1.
Me.GroupLevel(0).GroupInterval = 1
' Set KeepTogether property to With First Detail.
Me.GroupLevel(0).KeepTogether = 2
End Sub
KeepTogether
You can use the KeepTogether property for a group in a report to keep parts of a group (including the group header, detail section, and group footer) together on the same page. For example, you might want a group header to always be printed on the same page with the first detail section.
The KeepTogether property for a group uses the following settings.
CreateReport.GroupLevel.KeepTogether =
Properties
Returns a reference to a control's Properties collection object.
The Properties collection object is the collection of all the properties related to a control. You can refer to individual members of the collection by using the member object's index or a string expression that is the name of the member object. The first member object in the collection has an index value of 0, and the total number of member objects in the collection is the value of the Properties collection's Count property minus 1.
Private Sub cmdListProperties_Click()
ListControlProps Me
End Sub
Public Sub ListControlProps(ByRef frm As Form)
Dim ctl As Control
Dim prp As Property
On Error GoTo props_err
For Each ctl In frm.Controls
Debug.Print ctl.Properties("Name")
For Each prp In ctl.Properties
Debug.Print vbTab & prp.Name & " = " & prp.Value
Next prp
Next ctl
props_exit:
Set ctl = Nothing
Set prp = Nothing
Exit Sub
props_err:
If Err = 2187 Then
Debug.Print vbTab & prp.Name & " = Only available at design time."
Resume Next
Else
Debug.Print vbTab & prp.Name & " = Error Occurred: " & Err.Description
Resume Next
End If
End Sub
SortOrder
You use the SortOrder property to specify the sort order for fields and expressions in a report. For example, if you are printing a list of suppliers, you can sort the records alphabetically by company name.
The SortOrder property uses the following settings.
Reports("Product Summary").GroupLevel(0).SortOrder = False