Solved

Is there a way to use an option group on a form to open a report with the data in either ascending or descending order?

Posted on 2013-06-10
4
401 Views
Last Modified: 2013-06-11
Is there a way to use an option group on a form to open a report with the data in either ascending or descending order in the detail section of the report?
0
Comment
Question by:SteveL13
  • 2
  • 2
4 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 39236465
Yes, but we'd need to know more about the report.

Is it grouped? If so, then grouping always takes precedence over datasource filtering, or the Filter argument of the Report. You can change the Field your Group is based on through code, however, but that often makes the report oddly formatted.

If it's not grouped, then you can set the Orderby argument in the Open even of the report. You have to do a little magic to do this, but it's not too difficult:

In the Open event of the form, use code like this:

If Forms("FormWithYourOptionGroup").YourOptionGroup = 1 Then
  Me.OrderBy = "SomeField DESC"
Else
  Me.OrderBy = "SomeField"
End If

Me.OrderByOn = True

As stated, however, if your report is grouped this won't have any effect.

And obviously you'd have to change that code to reflect the values in the OptionGroup. If you've given the Option of "Descending" a value of 2, for example, you'd have to change the code to look for that.
0
 

Author Comment

by:SteveL13
ID: 39237646
There is no grouping on the report.  I'll try this.  

You wrote, "In the Open event of the form, use code like this:" but I assume you meant open event of the report, correct?
0
 
LVL 84
ID: 39238649
Yes - in the Open event of the REPORT. Sorry about that.
0
 

Author Comment

by:SteveL13
ID: 39238657
No problem.. I understood and accepted your solution.  Thanks much!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now