How do you want the records sorted? The sample you posted is Sorted by
Terminal_1.
If you want to sort by Cum_Dist from largest to smallest value, then you
need to change the order by clause. Perhaps to
ORDER BY 4 DESC , Val(Terminal_1)
or to the more complex
ORDER BY (SELECT SUM(Backspan_1)
FROM PED P
WHERE P.Route_1 = PED.Route_1
AND P.Terminal_1 <= PED.Terminal_1) ,
Val(Terminal_1)
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
MValentine said:
Are you saying that I should now have the following? I have tried this and
it
still does not list CUM_DIS in the correct sequence.
Thanks for your assistance.
SELECT PED.ROUTE_1, PED.TERMINAL_1, PED.BACKSPAN_1, (SELECT
SUM(Backspan_1)
FROM PED P
WHERE P.Route_1 = PED.Route_1
AND P.Terminal_1 <= PED.Terminal_1) AS Cum_Dist
FROM PED
WHERE (((PED.ROUTE_1)=[ Enter Route ]) AND ((PED.TERMINAL_1) Between [
ENTER
START ] And [ENTER END ]))
ORDER BY Val([TERMINAL_1]), 4;
Douglas J. Steele said:
That's probably because you haven't included it in your ORDER BY clause.
ORDER BY Val(TERMINAL_1), 4
--
Doug Steele, Microsoft Access MVP
(no private e-mails, please)
This worked and my sort is looking correct. However my field CUM_DIS is
not
in the correct sort sequence.
SELECT PED.ROUTE_1, PED.TERMINAL_1, PED.BACKSPAN_1, (SELECT
SUM(Backspan_1)
FROM PED P
WHERE P.Route_1 = PED.Route_1
AND P.Terminal_1 <= PED.Terminal_1) AS Cum_Dist
FROM PED
WHERE (((PED.ROUTE_1)=[ Enter Route ]) AND ((PED.TERMINAL_1) Between [
ENTER
START ] And [ENTER END ]))
ORDER BY Val(TERMINAL_1);
Below is a sample from the query:
ROUTE_1 TERMINAL_1 BACKSPAN_1 Cum_Dist
10B-14L 3 21 540
10B-14L 4 293 833
10B-14L 5 634 1467
10B-14L 6 455 1922
10B-14L 7 577 2499
10B-14L 8 322 2821
10B-14L 9 302 3123
10B-14L 10 267 267
10B-14L 11 252 519
Thanks for the help
Michael
:
On Mon, 25 Jun 2007 11:57:01 -0700, MValentine
I have created a query that reads an external dBASEIII file. The
field I
want
to sort on contains numeric values. However the dBASE file has the
field
defined as "text".
My query returns a sort which is like the following"
1
10
11
13
2
3
4....
Can I correct this so that my query is in the correct numeric
sequence?
Thanks
Michael
Sort by Val([fieldname]).
John W. Vinson [MVP]