Advanced filter/sort in MS access

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do you sort a text field alphabetically by the first letter of the field
while ignoring the numbers.
For example, I would like my records to be sorted as follows:
A
B
45-C
G
123-P
T
Thanks for your help
 
One way would be to write a function that returns the first letter in the
field, add a computed field to your query that returns the value of that
function and then sort on that computed field.
 
How do you sort a text field alphabetically by the first letter of the field
while ignoring the numbers.
For example, I would like my records to be sorted as follows:
A
B
45-C
G
123-P
T
Thanks for your help

The Text is always preceded by a hyphen?
Add a new column to your query.

SortThis:IIf(InStr([FieldName],"-")>0, Mid([FieldName],
InStr([FieldName], "-") +1),[FieldName])

Sort on this column.
 

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

Back
Top