I am trying to sort a report by code in order to avoid making five separate reports. I have a form that I am trying to reference when opening a report. The code is below which is in the report. The form has a option group created based on the commented out names with the values = to the Case number. Can someone tell me what is wrong? When I run the report it goes to debug and highlights the Select Case statement.
Private Sub Report_Open(Cancel As Integer)
Select Case Form!frmChooseSort!grpSort
Case 1 'State
Me.GroupLevel(0).ControlSource = "Date Bid"
Me.GroupLevel(1).ControlSource = "Low Bidder Code"
Me.GroupLevel(2).ControlSource = "State"
Case 2 'Capacity
Me.GroupLevel(0).ControlSource = "Date Bid"
Me.GroupLevel(1).ControlSource = "Low Bidder Code"
Me.GroupLevel(2).ControlSource = "Capacity"
Me.GroupLevel(3).ControlSource = "Tank Type"
Case 3 'TankType
Me.GroupLevel(0).ControlSource = "Date Bid"
Me.GroupLevel(1).ControlSource = "Low Bidder Code"
Me.GroupLevel(2).ControlSource = "Capacity"
Me.GroupLevel(3).ControlSource = "Tank Type"
Me.GroupLevel(4).ControlSource = "State"
Case 4 'TankType-State
Me.GroupLevel(0).ControlSource = "Date Bid"
Me.GroupLevel(1).ControlSource = "Tank Type"
Me.GroupLevel(2).ControlSource = "State"
Case 5 'Bidder-TankType
Me.GroupLevel(0).ControlSource = "Date Bid"
Me.GroupLevel(1).ControlSource = "Low Bidder Code"
Me.GroupLevel(2).ControlSource = "Tank Type"
End Select
End Sub
Private Sub Report_Open(Cancel As Integer)
Select Case Form!frmChooseSort!grpSort
Case 1 'State
Me.GroupLevel(0).ControlSource = "Date Bid"
Me.GroupLevel(1).ControlSource = "Low Bidder Code"
Me.GroupLevel(2).ControlSource = "State"
Case 2 'Capacity
Me.GroupLevel(0).ControlSource = "Date Bid"
Me.GroupLevel(1).ControlSource = "Low Bidder Code"
Me.GroupLevel(2).ControlSource = "Capacity"
Me.GroupLevel(3).ControlSource = "Tank Type"
Case 3 'TankType
Me.GroupLevel(0).ControlSource = "Date Bid"
Me.GroupLevel(1).ControlSource = "Low Bidder Code"
Me.GroupLevel(2).ControlSource = "Capacity"
Me.GroupLevel(3).ControlSource = "Tank Type"
Me.GroupLevel(4).ControlSource = "State"
Case 4 'TankType-State
Me.GroupLevel(0).ControlSource = "Date Bid"
Me.GroupLevel(1).ControlSource = "Tank Type"
Me.GroupLevel(2).ControlSource = "State"
Case 5 'Bidder-TankType
Me.GroupLevel(0).ControlSource = "Date Bid"
Me.GroupLevel(1).ControlSource = "Low Bidder Code"
Me.GroupLevel(2).ControlSource = "Tank Type"
End Select
End Sub