Sorting a report via code

TJBernard

Registered User.
Local time
Today, 08:51
Joined
Mar 28, 2002
Messages
176
I got great help here in the past with some code to sort my report through code, depending on choices a user makes on another form. Here is the code that I currently use and works correctly:

Select Case Forms!frmOpenIssueReport.frameOrder.Value
Case Is = 1
Me.GroupLevel(1).ControlSource = "MainIssueID"
Case Is = 2
Me.GroupLevel(1).ControlSource = "IssueName"
Case Is = 3
Me.GroupLevel(1).ControlSource = "IssueDate"
Case Is = 4
Me.GroupLevel(1).ControlSource = "Category"
End Select

This is placed on the Open Procedure of the report and works great. Now the users want to be able to sort the report by either Ascending or Descending. I have been playing with the code but have not found a way to do this. I tried Me.GroupLevel(1).SortOrder but it only allows True or False.

If anyone has any ideas it would be greatly appreciated.

Thank you,

TJBernard
 
Try:

If SomeBooleanValue = False Then
' Set SortOrder property to ascending order.
Me.GroupLevel(1).SortOrder = False
Else
' Set SortOrder property to descending order.
Me.GroupLevel(1).SortOrder = True
End If

Hth,

Doug.
 
It worked for me, thank you very much for your advice.

TJBernard
 
Rookies

I wish I could see the entire finished code you developed for this. Us ROOKIES need a little more help. Thanks
 
Select Case Forms!frmSelectPriority.frameOrder.Value
Case Is = 1
Me.GroupLevel(1).ControlSource = "MainIssueID"
Case Is = 2
Me.GroupLevel(1).ControlSource = "IssueName"
Case Is = 3
Me.GroupLevel(1).ControlSource = "IssueDate"
Case Is = 4
Me.GroupLevel(1).ControlSource = "Category"
End Select

If Forms!frmSelectPriority.frameAscDesc.Value = 2 Then
Me.GroupLevel(1).SortOrder = True
End If
--------------------------

Is my code in the open statement. The first case statement determines which field to sort the report by (is determined by a drop down list box on a form before the report is opened).

the If statement, is asking if the report is supposed to be sorted ascending or descending. If Ascending (Forms!frmSelectPriority.frameAscDesc.Value = 1) then the if statement is skipped over, if Descending, then it enters the if statment and Me.GroupLevel(1).SortOrder = True sets it as Descending.
 

Users who are viewing this thread

Back
Top Bottom