My Assistant
![]() ![]() |
|
|
Oct 24 2006, 12:29 PM
Post
#1
|
|
|
UtterAccess Addict Posts: 130 From: PA, USA |
I would like to open a report and sort the records. Is there a way to do this?
I have the command: CODE DoCmd.OpenReport Me.cboWhichReport, acViewPreview, , Filter This works for supplying where criteria, but not sorting or at least not the way I have been trying. Thanks |
|
|
|
Oct 24 2006, 01:17 PM
Post
#2
|
|
|
UtterAccess VIP Posts: 12,201 From: Tacoma, WA. |
Look at sorting and grouping within the report itself from the Sorting and Grouping Icon in the Toolbar
|
|
|
|
Oct 24 2006, 05:34 PM
Post
#3
|
|
|
UtterAccess Addict Posts: 130 From: PA, USA |
Yes, but if the the filter I am applying in the code needs to change the predefined sort order...what do I do?
|
|
|
|
Oct 24 2006, 06:12 PM
Post
#4
|
|
|
UtterAccess VIP Posts: 12,201 From: Tacoma, WA. |
Not to sure i can help you but what code are you using now?
|
|
|
|
Oct 24 2006, 07:09 PM
Post
#5
|
|
|
UtterAccess Addict Posts: 130 From: PA, USA |
CODE DoCmd.OpenReport Me.cboWhichReport, acViewPreview, , Filter So i thought I could set filter to be the sort clause... CODE Filter = "ORDER BY Field1" But I think that the Where clause requires it to be simply a where statement and not an order by statement |
|
|
|
Oct 24 2006, 07:12 PM
Post
#6
|
|
|
Utter A-fishin'-ado Posts: 17,723 From: Cincinnati, Ohio, USA . . . ><((((°> |
The filter has nothing to do with the Sort Order. Sorting and Grouping are handled within the report in the section John mentioned. How does filtering a report impact the sort order? All you are doing is limiting the records.
|
|
|
|
Oct 24 2006, 07:32 PM
Post
#7
|
|
|
UtterAccess Addict Posts: 130 From: PA, USA |
right, but can I do the sorting/grouping from the code of a form which is opening the report?
|
|
|
|
Oct 24 2006, 07:44 PM
Post
#8
|
|
|
Utter A-fishin'-ado Posts: 17,723 From: Cincinnati, Ohio, USA . . . ><((((°> |
If you needed this functionality I would write this code in the Report's OnOpen event and look to the form to get the options needed. See the following VBA properties/methods:
CreateGroupLevel method GroupOn property GroupInterval property GroupLevel property KeepTogether property SortOrder property Some of these may only be able to be set while the report is in Design view. Alternatively, you could just create two or more versions of the same report and call the appropriate one from the form. |
|
|
|
Oct 24 2006, 08:06 PM
Post
#9
|
|
|
UtterAccess Addict Posts: 130 From: PA, USA |
okay, that is an acceptable option. I will try the code first and then resort to the second report. Thanks
|
|
|
|
Oct 24 2006, 08:13 PM
Post
#10
|
|
|
Utter A-fishin'-ado Posts: 17,723 From: Cincinnati, Ohio, USA . . . ><((((°> |
NP.
|
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 18th May 2013 - 04:07 PM |