Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting

Status
Not open for further replies.

sdpsc

Technical User
Feb 10, 2001
76
In a database, there is a field of numbers, which I want to sort by. However, if I have the numbers 1 through 10, it orders it like '1, 10, 2, 3", like its ordering by the first digit. How do I make it order by the actual number?
 
You have to make this field a number field in access, and not a text field. Then it will work.
 
One option would be to cast it toa numeric type in your query. Without knowing your exact database I couldn't tell you the functions to use, but basically you would want something similar to:
Code:
sql_string = "SELECT * FROM MyTable ORDER BY cInt(myNumberField)"

The only problem with this method isa that since those are text fiels you my have some non-numeric entries (like blanks) that will cause the attempt to cast to give you a nasty error.

-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top