Provided by Andy Baron.
Access reports do their own sorting based on the sort fields you specify in the Sorting and Grouping dialog of the report. The recordsource Order By clause is ignored.
Microsoft has a knowledgebase article that explains a technique for using setting the OrderBy property of a report by opening the report in design view (Article ID: Q146310).
I have always preferred to programmatically set the group levels of the report, with code like this in the Open event of the report:
Select Case Forms!frmChooseSort!grpSort Case 1 'Name Me.GroupLevel(0).ControlSource = "LastName" Me.GroupLevel(1).ControlSource = "FirstName" Me.GroupLevel(2).ControlSource = "Company" Case 2 'Company Me.GroupLevel(0).ControlSource = "Company" Me.GroupLevel(1).ControlSource = "LastName" Me.GroupLevel(2).ControlSource = "FirstName" End Select
To make this work, you just need to make sure that you have set up the right number of grouping levels in the report's grouping and sorting dialog.
|Home||Index of tips||Top|