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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sorting of text field

Status
Not open for further replies.

pronate

Technical User
Jul 7, 2002
64
SG
Hi

I have a text field as primary key, need to sort it like this...

sen-01
sen-13
sen-152
sen-205
sen-1050
sen-1150

but access give me this:

sen-01
sen-1050
sen-1150
sen-13
sen-152
sen-205

I understand that because it is text field, the numbers behind are not considered as a single number, but on every digit. Any way to do it?

If not, I may want to convert is to number field, i guess i will have to drop the "sen". then again, in number field, will i able to enter preceeding zeros? eg: 01 and not 1.

Cheers
Sam

 
Sam,

Quick questions and then possible solution.....

Q: Do all the entries begin with "sen-"? Do you only need preceding zeros on numbers from 1 to 9?? i.e. 01,02,10,11,205,2678.

S: If the above is true, the following will work:

I created a table with one field that was data type Number. I applied the following properties and achieved the results you described.

FieldSize: LongInteger
Format: "sen-"00
DecimalPlaces: 0
InputMask: 999999 ' Just to ensure only numbers were entered

By using this, I created the same format you gave. Then I created a query of the table and sorted them ascending....They came out in the order you wanted... The secret to creativity is knowing how to hide your sources. - Albert Einstein [spin]

Robert L. Johnson III, A+, Network+, MCP
Access Developer/Programmer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top