Solved

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

Posted on 2013-05-15
3
561 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

Independent Software Vendors: 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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
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.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
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…

688 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