+ Reply to Thread
Results 1 to 7 of 7

Report changing Sort order

  1. #1
    Forum Contributor
    Join Date
    04-21-2010
    Location
    Canada
    MS-Off Ver
    Office 2013
    Posts
    120

    Report changing Sort order

    I have some data that is pulled from an SQL table with and SQL Statement. When viewing the data output, the sort order (by firstname then by lastname) looks good. When I run it through the report I made, the order gets messed up.

    my report is done up something fancy to generate a phone list. In the Group,Sort and Total, I have group on the field Dummy and then grouped on the field Heads.

    Dummy is a field generated at the SQL statement (1 as [Dummy]), and the grouping is made so that I can have a footer after the full detail, but before the page footer.

    Heads is a field generated at the SQL statement (LEFT(" & sortField & ", 1) AS Heads) which grabs the field designated as the sort field (first name or last name), which creates the letter Header for each detailed section. For example, the data output would look something like this:

    [=====A======]
    Amber Thomas
    Art Smith
    [=====B======]
    Ben Dover
    Blair Witch
    Burt Renolds

    ext.
    Well, that is what is should look like. But this order is messed up, and I'm not sure why. The data outputs properly in the query, but the order differs once it hits the report. The Heads groups are right, but the sorts between the letters is off. There is not Sort set in the Groups, Sort and Total area. Is there somewhere else that a sort could be implemented? My only Scripts for this report are to force the page to be landscape and 11x17 on Report_Open, and for formatting the height of the Detail area in the Details_Format
    Last edited by jik_ff; 12-05-2016 at 11:19 AM. Reason: Solved

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Report changing Sort order

    Right click on the returned data. From the resulting menu select External Data properties. Check the Preserve column sort/filter/layout box.

    And / or put an order by clause in your SQL.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Forum Contributor
    Join Date
    04-21-2010
    Location
    Canada
    MS-Off Ver
    Office 2013
    Posts
    120

    Re: Report changing Sort order

    There is a sort (Order By) clause in my SQL statement and that works fine. In access if I view the SQL in datasheet, it is sorted perfectly. The issue is caused by the report.

    I'm not sure I follow you on your first line of trouble shooting. Are you talking about the report? By default it is a print preview. I have tried viewing the report in report view, and right clicking on the report does not yield a menu with External Data Properties as an option. BTW, should say that I am using Access 2016. Please indicate what access object I should be clicking on and what state it needs to be in a the time. This sound like it may be what I am looking for...

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Report changing Sort order

    My apologies: I failed to pay attention to the forum - I was answering as if this were an Excel question.

  5. #5
    Forum Contributor
    Join Date
    04-21-2010
    Location
    Canada
    MS-Off Ver
    Office 2013
    Posts
    120

    Re: Report changing Sort order

    No problem. This has happened before. Ah well... Will wait for another passer by...

  6. #6
    Forum Contributor
    Join Date
    04-21-2010
    Location
    Canada
    MS-Off Ver
    Office 2013
    Posts
    120

    Re: Report changing Sort order

    Ok, on rebuilding a more basic version of the phone list report, I seem to have found where the issue is occurring. It appears that the grouping for Dummy is the cause. Even though the value for Dummy is the same for every record (=1), when that group is turned on, the sort goes wacky. I cannot tell what it is try to sort by.

    Ok, I guess I have to explain the reason for the Dummy Group. The phonelist populates an 11x17 page. On that page there are 6 columns. So down the first column, it starts with A, then B, then C until it runs down the bottom of the page, then pops over to the top of the next column to continue. All good. But (as a request form the powers that be) they want all the Meeting room info also listed at the end of the list. And An area for 'other' phone numbers, then a section for local emergency numbers. For this to populate at the end of the regular numbers, I cannot put it in the details footer, as it would go after each name. Can't put it in the Heads footer, or it would appear after each letter section. The footer is populated with other phone information about field offices.

    Really, this is the only way I can get it to display the way they want. I need to put this stuff at the end of all the details, but before the page footer. Not sure why it is trying to sort something that has all the same value...

    Basically, I need to find a way to group without sorting. Either that or I guess I could try to generate the Group and Sorting on the Report Open event? The SQL statement to create the data (and sorting) is done from selections made on hard coded combo boxes. I would need to be able to pull values from the script that calls up the report....

    Ya, like to do things the hard way....
    Last edited by jik_ff; 12-02-2016 at 05:38 PM.

  7. #7
    Forum Contributor
    Join Date
    04-21-2010
    Location
    Canada
    MS-Off Ver
    Office 2013
    Posts
    120

    Re: Report changing Sort order

    OK, found the solution, though it eluded me for a while... What I wanted to sort by was a field that was generated in the SQL statement (named OutText). This text is dynamic based on selections made from the form.

    In any case, prior to making it dynamic, my grouping looked like this:
    Group on Dummy
    +>Group on Heads
    +>Sort by LastName
    +>Sort by ShowName

    When I attempted to use the OutText field in the sort under the Heads group, the selection was not available. I thought it might be because the field is generated from the SQL statement. But then I noticed that a few other 'flag' fields showed up as selectable. At the bottom of the drop down was 'expression'. So I selected that, and set the expression to be [OutText]. That worked. All that running around most likely because I had too many fields to see the one I wanted on the list...


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 4
    Last Post: 03-17-2015, 04:36 AM
  2. Sort the final digits and sort in ascending order
    By jorel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-29-2014, 11:58 AM
  3. Change order of Legend without changing the order of the chart
    By Grimace in forum Excel Charting & Pivots
    Replies: 6
    Last Post: 11-22-2012, 11:53 AM
  4. Replies: 4
    Last Post: 11-20-2012, 06:00 PM
  5. Changing Sort order
    By dkril in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-30-2009, 12:03 PM
  6. Changing report to auto sort
    By bigbear in forum Excel General
    Replies: 3
    Last Post: 03-06-2008, 01:55 PM
  7. [SOLVED] Pls. reply Sort Data and copy to next coulmn when sort order chang
    By shital shah in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-19-2005, 10:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1