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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…

860 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