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
410 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 85

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 85
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

630 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