Results 1 to 5 of 5
  1. #1
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328

    Sort query a by a calculated control

    Using aA2007. I have an append query that I would like to sort by the expression:

    Corr_Final: IIf([handicapSystem]=2,[Corr_TonT],[Corr_TonD])

    Corr_TonT and Cor_TonD are calculated values. When I try to sort query using Corr_Final, I get a message about parameter values for the two options.. I found one website that claimed that I should be able to sort, but it didn't work.



    Is it possible to sort or do I have to create another query just to be able to sort?

    Any help much appreciated.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Post the full query SQL statement.

    If this query is an aggregate type, then won't work. Would have to repeat the calcs for Corr_TonT and Corr_TonD in the Corr_Final expression.

    Do you have link to that site?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    Thanks for quick reply. It isn't an aggregate query (As I understand it, aggregate means queries that include groupby, avg etc). The site I was looking at and couldn't understand is: http://msgroups.net/microsoft.public...ed-field/95440

    The sql:
    SELECT RaceResultsRawData.id, RaceResultsRawData.SponsorYC, RaceResultsRawData.Year, RaceResultsRawData.Series, RaceResultsRawData.RaceNo, RaceResultsRawData.Fleet, RaceResultsRawData.handicapSystem, IIf([handicapSystem]=2,[Corr_TonT],[Corr_TonD]) AS Corr_Final, [elapsed]-[PHRF]*[distance]/86400 AS Corr_TonD, [elapsed]*[A]/([B]+[PHRF]) AS corr_TonT, ([findate1]-[startdate1]+[finishtime]-[startTime]) AS Elapsed, RaceResultsRawData.phrf, 3600/([elapsed]/[distance]) AS speed, RaceResultsRawData.status, RaceResultsRawData.[Boat Class]
    FROM RaceResultsRawData
    ORDER BY RaceResultsRawData.SponsorYC, RaceResultsRawData.Year, RaceResultsRawData.Series, RaceResultsRawData.RaceNo, RaceResultsRawData.Fleet, IIf([handicapSystem]=2,[Corr_TonT],[Corr_TonD]);

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Okay, guess I've never had to do filter/sort like this. It is possible to refer to the calculated fields in other calculations to construct another field, but apparently not in the WHERE or ORDER BY clauses.

    Yes, can apply filter/sort on calculated field (I have done that) but if that calc includes calculated fields, have to repeat the calcs (which I just confirmed in a test).
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    Thanks so much for quick and detailed follow up. -Not what I hoped to hear, but I can quit looking and get back to doing it.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 06-05-2012, 08:31 PM
  2. Sort Calculated Ages in to Age Groups
    By l3111 in forum Queries
    Replies: 2
    Last Post: 06-09-2011, 04:33 AM
  3. adding a sort control button
    By darklite in forum Forms
    Replies: 5
    Last Post: 01-24-2011, 03:32 PM
  4. Replies: 4
    Last Post: 10-01-2010, 12:06 PM
  5. a-z sort for control button
    By darklite in forum Access
    Replies: 7
    Last Post: 05-28-2010, 04:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums