Group: microsoft.public.access.reports
From: =?Utf-8?B?aGRmaXhpdHVw?=
Date: Tuesday, October 23, 2007 8:47 AM
Subject: Re: Sort Order

Here's where I am at so far:

Function Print_Report()
On Error GoTo Print_Report_Err
Dim Counter As Integer
Dim ReportDest As String
'Hide the form PrintReportsDialog
Forms![PrintReportsDialog].Visible = False
'Destination is Print Preview
If Forms![PrintReportsDialog]![Type of Output] = 1 Then
ReportDest = acNormal
Else 'Destination is Printer
ReportDest = acPreview
End If
With CodeContextObject
' Attached to the Print button on the PrintReportsDialog form

Select Case .[Report to Print]
Case 1 'Orders
'Print Order Report
Do While Counter < .[Number of Copies]
If Forms![PrintReportsDialog]![Select Order Type] = 1 And
Forms![PrintReportsDialog].[Select Number Both] = 1 Then
DoCmd.OpenReport "rptOrder", ReportDest, ,
Eval("IIf(Forms![PrintReportsDialog]![Select List] Is Null,"""",""[OrderID] =
Forms![PrintReportsDialog]![Select List]"")")
End If
If Forms![PrintReportsDialog]![Select Order Type] = 1 And
Forms![PrintReportsDialog].[Select Number Both] = 2 Then
DoCmd.OpenReport "rptOrderJ", ReportDest, ,
Eval("IIf(Forms![PrintReportsDialog]![Select List] Is Null,"""",""[OrderID] =
Forms![PrintReportsDialog]![Select List]"")")
End If

I currently have 20 Cases that follow this one. In this example, I want to
eliminate the second If statement rptOrderJ and use rptOrder only for Case 1.
I will add an option group on the PrintReportsDialog form allowing a sort
choice(either Number 1 or Number 2). I read your Case example that you
pointed me to. How do I incorporate another Case 1 or Case 2 within my Case
1 already? I am listing 4 group levels on the Sort/Grouping Dialog Box of the
report. Group - Ascending Subgroup - Ascending Number1 - Ascending
Number2 Ascending. I feel I am so close. Any help appreciated. Thanks

"Allen Browne" wrote:

> It's just a matter of assigning the ControlSource of the GroupLevel
>
> Example here:
> Sorting report records at runtime
> at:
> http://allenbrowne.com/ser-33.html
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "hdfixitup" wrote in message
> news:F31CC480-F6D3-4662-90BF-4926BCC09013@microsoft.com...
> >I currently use two reports so I can sort on two different fields. I would
> > like to have one report with two fields (Number1 and Number2). From a
> > Option
> > Group on a form, I would select Sort Order - either Number 1 or Number 2.
> > When the report opens, it would sort based on my selection in ascending
> > order. What do I need to place in the Sorting and Group Options on the
> > report
> > and what code needs to be added to the OnOpen event of the report? Can
> > anyone help me? I have tried numerous possibilities with no such luck.
>
>