Results 1 to 6 of 6
  1. #1
    SuperDude_123 is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2018
    Posts
    11

    Order by not working so well


    Could someone point out why my order by isn't working after all is said and done?

    Code:
    SELECT Database.*FROM [Database]
    WHERE ( Symbol like '*' + [Forms]![Form for 3 Filters].[Filter_1] + '*')
    	and Database.[Job Number] is not null
    	and Database.[Job Number] in (
    		SELECT  Database.[Job Number]
    FROM [Database]
    		where 
    		( Symbol like '*' + [Forms]![Form for 3 Filters].[Filter_2] + '*')
    and Database.[Job Number] is not null
    	)
    and Database.[Job Number] in (
    		SELECT  Database.[Job Number]
    FROM [Database]
    		where 
    		( Symbol like '*' + [Forms]![Form for 3 Filters].[Filter_3] + '*')
    and Database.[Job Number] is not null
    	)
    
    
    UNION
    
    
    (SELECT Database.*
    FROM [Database]
    WHERE ( Symbol like '*' + [Forms]![Form for 3 Filters].[Filter_2] + '*')
    	and Database.[Job Number] is not null
    	and Database.[Job Number] in (
    		SELECT  Database.[Job Number]
    FROM [Database]
    		where 
    		( Symbol like '*' + [Forms]![Form for 3 Filters].[Filter_1] + '*')
    and Database.[Job Number] is not null
    	)
    and Database.[Job Number] in (
    		SELECT  Database.[Job Number]
    FROM [Database]
    		where 
    		( Symbol like '*' + [Forms]![Form for 3 Filters].[Filter_3] + '*')
    and Database.[Job Number] is not null
    	))
    
    
    UNION (SELECT Database.*
    FROM [Database]
    WHERE ( Symbol like '*' + [Forms]![Form for 3 Filters].[Filter_3] + '*')
    	and Database.[Job Number] is not null
    	and Database.[Job Number] in (
    		SELECT  Database.[Job Number]
    FROM [Database]
    		where 
    		( Symbol like '*' + [Forms]![Form for 3 Filters].[Filter_1] + '*')
    and Database.[Job Number] is not null
    	)
    and Database.[Job Number] in (
    		SELECT  Database.[Job Number]
    FROM [Database]
    		where 
    		( Symbol like '*' + [Forms]![Form for 3 Filters].[Filter_2] + '*')
    and Database.[Job Number] is not null
    	))
    ORDER BY [Job Number];

  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
    How is it not working? Is it perhaps giving you an alphabetic sort when you're expecting a numeric sort?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    SuperDude_123 is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2018
    Posts
    11
    Yes, and the Job Numbers are just numbers. Could it be that I have it nested incorrectly?

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    If these are numbers stored in a text field, it will sort 'alphabetically'
    E.g. 1,11,12,13....2,20,21...3,31 etc
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  5. #5
    SuperDude_123 is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2018
    Posts
    11
    Shoot! I'm looking to order it in terms of 1,2,3,......11,12,13,....etc

    Should I use something else?

  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
    I'll get out of the way.
    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. Replies: 13
    Last Post: 11-12-2017, 01:27 AM
  2. Replies: 8
    Last Post: 09-18-2015, 01:52 PM
  3. Working with Different Order Services
    By francogaspari in forum Access
    Replies: 2
    Last Post: 06-18-2014, 09:22 AM
  4. order by dlookup not working
    By broof in forum Queries
    Replies: 3
    Last Post: 01-11-2011, 03:15 PM
  5. Forms Order By not working
    By cowboy in forum Forms
    Replies: 3
    Last Post: 04-21-2010, 10:29 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