Solved

How to disable or change the report Sort option in Access 2007 using vba

Posted on 2013-05-15
3
550 Views
Last Modified: 2013-05-16
I have a report where under the Group and sorting options I have only one sort option selected. No grouping.  I want to use this report for another means and need to be able to either remove that Sort in the report open event or at least change the field that the report is sorting on.  I can do this for Groupings, but cannot find any code for a sort only. the OrderBy has no effect. Trying to access GroupLevel(0) returns an error. Any ideas on how I can change this sort using vba?
0
Comment
Question by:BradleyCleveland
[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
3 Comments
 
LVL 3

Accepted Solution

by:
pjevin earned 500 total points
ID: 39169608
You could set the recordsource in the on open event and put your ordering in the sql statement.
Dim SQL as string
SQL = //put your sql query here
Me.RecordSource = SQL
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 39170450
<the OrderBy has no effect.>
Are you quite sure you are using it correctly?
Can you post the code you were trying...

In order for me.Orderby to work, it must be followed by:
    Me.OrderByOn = True
....and note that the report must be opened in "Print Preview" explicitly for this to work.

This has worked fine for me for years...

basic sample attached
Database241.mdb
0
 
LVL 1

Author Closing Comment

by:BradleyCleveland
ID: 39172519
This looks like it will work.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

730 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