[AccessD] Question on order within a union query

Michael R Mattys mmattys at rochester.rr.com
Wed Aug 8 09:16:18 CDT 2007


Very nice and simple, Gustav.
That's a keeper. :)

Michael R. Mattys
MapPoint & Access Dev
www.mattysconsulting.com

----- Original Message ----- 
From: "Gustav Brock" <Gustav at cactus.dk>
To: <accessd at databaseadvisors.com>
Sent: Wednesday, August 08, 2007 10:04 AM
Subject: Re: [AccessD] Question on order within a union query


> Hi Tom
>
> Yes, include in each of the sections of the union query an expression to 
> sort on, like:
>
>  SELECT 1 AS SortID, ...
>  UNION ALL
>  SELECT 2 AS SortID, ...
>
> Then Order By SortID as the first field and those fields, you currently 
> sort on, as the next field(s).
>
> /gustav
>
>>>> ewaldt at gdls.com 08-08-2007 15:45 >>>
> I'm converting an Excel workbook to Access, to add functionality and
> better ability for several people to use it at the same time. I've created
> the tables, relationships, etc., with no problem. However, I would like
> suggestions in one area.
>
> The user likes a spreadsheet report in the original workbook. I'd like to
> imitate it for him within Access. This spreadsheet includes several lines
> of data (easily duplicated within Access via query), the columns
> subtotals, two more corresponding rows of data (i.e., the columns
> correspond, but the rows are different), and a final totals line.
>
> I've put together all of the information via queries. I then combine the
> queries via a union query, but it insists on mixing the lines together,
> alphabetically, by the first column/field. I'm looking for a good way to
> avoid this. Is there a key word, command, etc., to tell Access to leave
> things in the order they're found?
>
> If not, do you have recommendations on how to achieve what I want in a
> different way?
>
> TIA.
>
> Thomas F. Ewald
> Stryker Mass Properties
> General Dynamics Land Systems
>
>
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com 




More information about the AccessD mailing list