B
Barry
I have a form with two comboboxes populated with the names of the
fields in a report's underlying query. The report picks up these
selections and sets the GroupLevels when it opens. This is pretty
standard stuff.
However, I can't get the GroupLevels to appear in the correct order;
they seem to be stuck in the order they are in in the Sorting/Grouping
dialog.
Here's my code:
Private Sub Report_Open(Cancel As Integer)
Dim strGroupBy1 As String
Dim strGroupBy2 As String
With Forms!frmPrintReports
If Not IsNull(.cboGroupBy1) Then
strGroupBy1 = .cboGroupBy1
Else
strGroupBy1 = "=1"
End If
If Not IsNull(.cboGroupBy2) Then
strGroupBy2 = .cboGroupBy2
Else
strGroupBy2 = "=1"
End If
End With
With Me
.GroupLevel(0).ControlSource = strGroupBy1
.GroupLevel(1).ControlSource = strGroupBy2
.GroupLevel(2).ControlSource = "=1"
.GroupLevel(3).ControlSource = "=1"
.GroupLevel(4).ControlSource = "=1"
.GroupLevel(5).ControlSource = "=1"
If strGroupBy1 <> "=1" Then
.Section(strGroupBy1 & "Header").Visible = True
.Section(strGroupBy1 & "Footer").Visible = True
End If
If strGroupBy2 <> "=1" Then
.Section(strGroupBy2 & "Header").Visible = True
End If
End With
End Sub
Any help would be appreciated.
fields in a report's underlying query. The report picks up these
selections and sets the GroupLevels when it opens. This is pretty
standard stuff.
However, I can't get the GroupLevels to appear in the correct order;
they seem to be stuck in the order they are in in the Sorting/Grouping
dialog.
Here's my code:
Private Sub Report_Open(Cancel As Integer)
Dim strGroupBy1 As String
Dim strGroupBy2 As String
With Forms!frmPrintReports
If Not IsNull(.cboGroupBy1) Then
strGroupBy1 = .cboGroupBy1
Else
strGroupBy1 = "=1"
End If
If Not IsNull(.cboGroupBy2) Then
strGroupBy2 = .cboGroupBy2
Else
strGroupBy2 = "=1"
End If
End With
With Me
.GroupLevel(0).ControlSource = strGroupBy1
.GroupLevel(1).ControlSource = strGroupBy2
.GroupLevel(2).ControlSource = "=1"
.GroupLevel(3).ControlSource = "=1"
.GroupLevel(4).ControlSource = "=1"
.GroupLevel(5).ControlSource = "=1"
If strGroupBy1 <> "=1" Then
.Section(strGroupBy1 & "Header").Visible = True
.Section(strGroupBy1 & "Footer").Visible = True
End If
If strGroupBy2 <> "=1" Then
.Section(strGroupBy2 & "Header").Visible = True
End If
End With
End Sub
Any help would be appreciated.