Results 1 to 2 of 2
  1. #1
    KikoMatsing is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Aug 2014
    Posts
    1

    Question ASC or DESC Sort Based On Another Field

    I have a query that lists items in locations in our warehouse. Each location is broken down by Aisle-Bay-Level-Position, for example 50-101-01B; or 51-106-02 with all the even Bays on one side and Odd bays on the other side of the aisle. I have the query set up so it separates odd and even so I can go all the way down one side of the aisle then I have to walk back to the beginning of the aisle to check the other side. What I am trying to do is change the sort based on another field that I have called SORT with a value of AZ or ZA depending on if I need that section to be sorted ASC or DESC. So for example all even bays in aisle 51 need to be sorted DESC while all ODD bays would be ASC. The way our warehouse is laid out it is not always the odd or even side that needs to be sorted DESC, that's why I made the SORT field. The formula I used for the SORT field is as follows:

    SORT: IIf(([Aisle]='50' And [OE]='ODD') Or ([Aisle]='51' And [OE]='ODD') Or ([Aisle]='53' And [OE]='ODD') Or ([Aisle]='52' And [OE]='EVEN'),'AZ','ZA')

    Is there a way to make it sort the BAY in ASC or DESC based on the value in SORT?

    As an example here is how I want the order to be:

    50-101-01A
    50-101-01B
    50-103-02A
    50-103-02B
    51-101-01
    51-103-01
    51-102-01
    51-136-01
    51-134-01
    51-132-01
    52-136-01
    52-134-01


    52-132-01
    52-101-01
    52-101-02
    52-103-01
    52-103-02
    53-101-01
    53-101-02
    53-103-01
    53-103-02
    53-136-01
    53-134-01
    53-132-01

    Hope my post is not too confusing...

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    You could use VBA to evaluate the value of Sort and then generate a string based on the evaluation. You could assign the resulting string to the property of an Object and or Control.

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

Similar Threads

  1. Asc/Desc/reset sort button code
    By mightyteegar in forum Programming
    Replies: 2
    Last Post: 10-30-2012, 04:24 PM
  2. Sort numbers based on second digit
    By Dale S in forum Queries
    Replies: 1
    Last Post: 05-16-2012, 07:06 AM
  3. Replies: 11
    Last Post: 12-21-2011, 09:48 AM
  4. ORDER BY error when using DESC in an IIf
    By Smitoris in forum Queries
    Replies: 2
    Last Post: 10-30-2011, 02:48 AM
  5. Report Based on Form - Sort
    By jeffyyy in forum Reports
    Replies: 1
    Last Post: 10-16-2010, 06:15 PM

Tags for this Thread

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