Results 1 to 8 of 8
  1. #1
    Jojojo is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Oct 2011
    Posts
    46

    Complex Sort

    I'm wondering if this is even possible....



    I have the following query:
    Classes: [EventName] & ": " & [ClassDay] & "'s at " & [StartTime]
    Sort: Ascending

    It produces the following:
    Kickboxing: Friday's at 5:00pm
    Kickboxing: Monday's at 5:00pm
    Kickboxing: Wednesday's at 5:00pm

    Is there any I can sort it, so that is still sorts ascending, class name first, but then by day of the week? So that Monday classes come first, then Tuesday etc? And if so, can I do the same thing with the time? I can't split apart the fields, I need them to show as above in 1 combo box.

    Thanks!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I'd probably include the fields separately in the query, and sort on them. They can be hidden so the user doesn't see them. You will need the numeric equivalent of the day, rather than the text.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Jojojo is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Oct 2011
    Posts
    46
    I am having problems getting the numeric value of the day to work. When a class is set up - the user selects what day of the week the class runs on, ex: Monday, Tuesday etc- via combo box. The weekday, weekdayname etc functions - from what I am reading work on a actual date entered. I've tried a few variations of them and when they do give me a number - its the same number regardless of what the user selected - so I will see all 2's etc.

    I'm not sure what function to use so that is the ClassDay entered is Monday - it returns 1, if Tuesday = 2 etc...

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I can't think offhand of a way to get from name to number with a function. You can have a table that associates name and number and join it in this query, which will let you get the number.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    As pbaldy said, include the fields individuallly in query, but just as sort criteria, don't display. Keep the concatenated value for display. Use Weekday() function to get the day of week number and use as sort criteria.
    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.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    OP has already mentioned that the Weekday function doesn't work, which is not surprising if the day is stored as "Monday" as it appears to be.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Oh, I missed that, assumed there was a date field that could be referenced. Then can use a custom function or nested IIF or Switch Function, like:

    Switch([ClassDay]="Monday",1, [ClassDay]="Tuesday",2, [ClassDay]="Wednesday",3, [ClassDay]="Thursday",4, [ClassDay]="Friday",5, [ClassDay]="Saturday",6, [ClassDay]="Sunday",7)
    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.

  8. #8
    Jojojo is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Oct 2011
    Posts
    46
    Thank you both - June7: that worked!!!!!

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

Similar Threads

  1. Sort problem
    By Bear in forum Forms
    Replies: 1
    Last Post: 08-21-2011, 10:32 PM
  2. Sort Query
    By jice89 in forum Queries
    Replies: 3
    Last Post: 05-06-2011, 05:56 PM
  3. Sort by even or odd number
    By sammer021486 in forum Queries
    Replies: 7
    Last Post: 11-23-2009, 12:30 PM
  4. How to sort by three sort orders
    By captgnvr in forum Access
    Replies: 4
    Last Post: 11-09-2009, 07:30 AM
  5. Sort
    By mmp97 in forum Access
    Replies: 1
    Last Post: 12-18-2008, 10:14 PM

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