Sort

fenhow

Registered User.
Local time
Today, 12:27
Joined
Jul 21, 2004
Messages
599
Hi, I have a table with a field called "Payment" this has one final payment called Residual all others are numbered 1-24 for an example. I am trying to figure out how I can force the table to sort 1-24 and then make Residual the last record?
Thanks.
 
You've got bigger problems than the issue you stated. Text doesn't sort like numbers, so the 'Residual' value is the least of your worries. Your field is going to sort like this:

1
10
11
12
13
...
2
20
21
22
23
24
3
4


So, if you want your data to sort properly, you should change the Payment field to numeric. Then make the residual payment be 25. That way it sorts properly...

But I want it to say 'Residual'

Well, you can do that in a query by creating a calculated field based on Payment. It would look like this:

PaymentValue: Iif(Payment=25, "Residual", Payment)
 
Great, thanks. So what if I had 36 payments not 24. Is there a way to calculate the last number in the DB with the IIF stmt?
Fen
 
use a query instead to sort your table:

select *, format([Payment], "00") As SortOrder From [yourtable] ORDER BY format([Payment], "00")
 

Users who are viewing this thread

Back
Top Bottom