Hello All!
I have three reports that are essentially identical. If I change one, I have to go change the other two. I'm hoping I can use an option group and select case to use only ONE report and the user selects which one and the report opens.
Except, I'm seeing some conflicting stuff as I do my research and I'm coming to you all for clarification.
My "base report" is called "rpt Troop Roster". I stripped out any sorting or grouping from the underlying query and from the report itself.
I see that I can use GroupLevel(0) to control all sorts of things ... just what I need! But, it looks like the GroupLevel(0) code needs to be in the Report_Open event.
My reports are not simply a different sort order ... they also have different grouping levels. One has only one sort order and no grouping while another has two sortings, followed by a grouping, followed by two more sortings.
So, I'd think that maybe I can't use the Report_Open event.
OR ... maybe that's exactly where I should put the code and pass an open args to the report_open and so a select case there?
Right now, here's what I have:
I don't have the code written for the second and third reports, and I know that using "SortOrder = True" actually reverses the sorting. I did that so i could see that my code really worked.Code:Private Sub cmdTrpRoster_Click() Dim optGroup As Integer Dim rptName As String optGroup = "ogRptGrp" rptName = "rpt Troop Roster" Select Case Me.ogRptGrp.Value Case 1 GoTo ByTroop Case 2 GoTo BySchool Case 3 GoTo ByLevel End Select ByTroop: DoCmd.OpenReport rptName, acViewReport rptName.GroupLevel(0).ControlSource = "Troop Number" rptName.GroupLevel(0).SortOrder = True BySchool: Exit Sub ByLevel: Exit Sub End Sub
The code hangs on the first rptName.GroupLevel(0) line. It says "Invalid Qualifier"
So, should I put the grouping code in the report_open event? Would I pass the option group value to the report and then do the select case?
Thank you all!
Susie
Kansas