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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How Can I Grab This Information off a PDF Form 23 49
Access 2003 query lost it's only join 7 27
Help with DoEvents 8 28
MS Access Delete All Excel sheets 1 9
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

809 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