Of Zen and Computing

Sort An Alphanumeric Column Properly in Microsoft Access

Digg icon StumbleUpon icon del.icio.us icon Facebook icon

Have you ever been frustrated by the way Microsoft Access sorts text columns that contain alphanumeric content? Consider the following records:

Unordered Access alphanumeric table

If you were to sort by this column, this is how your final result would look:

Alphanumeric column ordered in Access

Microsoft Access queryTechnically, this is correct. Realistically, I’d guess that you were hoping for the results to be ordered 1, 1d, 10a, 14, 24a, 24c, instead. To get the desired result, you’ll need to create a query that splits the content of this column into two parts - one part number, one part letter. Then, sort primarily by number and secondarily by letter. The Microsoft Knowledge Base article “How to Sort Alphanumeric Strings Based on Their Numeric Portions” describes exactly how to create this query. If you follow Microsoft’s instructions, query will look like the one shown here.

Switch the query over to the datasheet view, and here’s the final result:

Microsoft Access query output

File under: Software, Tips & Tricks

Other articles related to this page

0 responses

  1. There are no comments yet... be the first and leave yours below.

Leave a Comment

RSS Feed Icon comment feed