Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    513

    simple syntax ?

    I have a query [qryFixtureType_sort normal] which includes 2 expressions that the query is sorted on (exp1, exp2); and the query results in a correctly sorted datasheet;
    I am using that query as the datasource for a listbox.

    the field that I want to display in the listbox is the unfortunately named (I inherited it, and it seems to be used EVERYWHERE -UGH!): "Type"


    when I enter the source as below, the full recordset is included, and it is sorted correctly
    [qryFixtureType_sort normal.Type]

    when I include a union, as either of the below - which is ultimately what I want, the full recordset is included, but it is not sorted




    SELECT [qryFixtureType_sort normal.Type] FROM [qryFixtureType_sort normal] UNION Select "< ALL >" FROM [qryFixtureType_sort normal];

    SELECT [qryFixtureType_sort normal.Type] FROM [qryFixtureType_sort normal] ORDER by exp1, exp2 UNION Select "< ALL >" FROM [qryFixtureType_sort normal];


    any thoughts would be greatly appreciated in advance
    Mark

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Build your union query first. Base the listbox on a query of the union query ordering it to sort the way you want it. That's probably the easiest way

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    The only place you can have an ORDER BY clause is in the last SELECT statement, though it would need to use field names from the first. More accurately, that's the only place it will work.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. simple SQL syntax with hyperlink
    By markjkubicki in forum Programming
    Replies: 2
    Last Post: 01-18-2012, 06:58 PM
  2. Simple Criteria syntax mismatch - please help!
    By whatwouldmattdo in forum Queries
    Replies: 4
    Last Post: 10-19-2011, 04:57 PM
  3. Simple code syntax question
    By mseeker22 in forum Programming
    Replies: 1
    Last Post: 07-07-2011, 03:55 AM
  4. Simple Syntax Help
    By cvegas in forum Programming
    Replies: 7
    Last Post: 04-20-2011, 01:46 PM
  5. simple syntax question
    By markjkubicki in forum Programming
    Replies: 6
    Last Post: 09-14-2010, 04:13 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