grouping items based on last three digits

J

johnk

I have a large list of related items for exapmle:
abc-123, abc-234, abc-345, bcd-123, bcd-234, bcd-345, cde-123,cde-234,
cde-345
I need to have them sorted on the last three digits, so I end up with:
abc-123, bcd-123, cde-123 and so on. How do I do this?
 
F

fredg

I have a large list of related items for exapmle:
abc-123, abc-234, abc-345, bcd-123, bcd-234, bcd-345, cde-123,cde-234,
cde-345
I need to have them sorted on the last three digits, so I end up with:
abc-123, bcd-123, cde-123 and so on. How do I do this?

Add 2 new columns to your query.
FirstSort:Right([FieldName],3)

If the beginning of the data is always 3 characters:
SecondSort:Left([FieldName],3)

If the beginning characters can be more than 3 characters, then use:
SecondSort:Left([FieldName],Len([FieldName])-4)

Make sure the columns are in the above order.
Sort on these columns.

Note.. If this query is the record source of a report, the above
sorting is irrelevant. Use the same 2 new columns in the report's
Sorting and Grouping dialog to sort in the report.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top