sorting addresses

G

Guest

I am trying to sort a field that is 345 south main street, when I sort the
column of address they appear lowest numeric number first.
How do I convert 345 south main street and so on that is in one field to 2
fields: 345; south main street, so that the sort works properly?
 
K

Ken Snell \(MVP\)

Use two calculated fields in the query as the sort fields. Something like
this:

SELECT * FROM Tablename
ORDER BY Trim(Left([AddressField], InStr([AddressField, " ")-1)),
Trim(Mid([AddressField], InStr([AddressField, " ")+1));
 
K

Ken Snell \(MVP\)

To add to my post, you might have to cast the first part of the field as a
number to get numeric order sorting:

SELECT * FROM Tablename
ORDER BY CLng(Trim(Left([AddressField], InStr([AddressField, " ")-1))),
Trim(Mid([AddressField], InStr([AddressField, " ")+1));
 

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