Results 1 to 3 of 3
  1. #1
    Smitoris is offline Novice
    Windows Vista Access 2007
    Join Date
    Sep 2011
    Posts
    6

    ORDER BY error when using DESC in an IIf

    I have a query in which I use something to the effect of the following in the ORDER BY clause:



    Code:
    ORDER BY IIf((Element.Division = 4 or Element Division = 7), [Element.A] & [Element.B] & [Element.Z], [Element.D] & [Element.B] & [Element.Z])
    I want the [Element.Z] to sort in descending order but when I add DESC after it Access is throwing an error.

    Any idea how to make this work? Thanks in advance.

    Neal

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    You are missing the dot in the second Element.Division
    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
    Smitoris is offline Novice
    Windows Vista Access 2007
    Join Date
    Sep 2011
    Posts
    6
    I omitted the period on accident. I figured this out, though.

    The issue is that you cannot sort DESC within a concatenation. I moved the last field to sort on outside of the IIf statement and it works.

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

Similar Threads

  1. Order By Subquery
    By dfenton21 in forum Access
    Replies: 1
    Last Post: 09-07-2011, 07:43 PM
  2. Id Order
    By Rockin-John in forum Forms
    Replies: 15
    Last Post: 05-03-2011, 02:39 PM
  3. How to use Rnd to order records?
    By Gdm in forum Queries
    Replies: 1
    Last Post: 05-26-2010, 09:01 PM
  4. Order by
    By cowboy in forum Access
    Replies: 2
    Last Post: 05-03-2010, 05:04 PM
  5. Tabbing order
    By emccalment in forum Forms
    Replies: 1
    Last Post: 02-18-2010, 10:58 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