Solved

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

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

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
Add records to a form to a table 11 41
How can I Flash a mandatory field in Access Form? 13 48
Combobox row source 2 21
Access: Retrieving Current Month's Orders for Invoice 6 29
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…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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…

803 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