Sorting by the year first without using 4 digits will be difficult, but not
impossible. Allen's suggestion of 3 fields, sorting as needed on each field
is a good one. You could then concatenate them together for display
purposes.
By your description, the leading numbers and initials should sort correctly
if the year was removed and you want to sort by the year first. Without
breaking this into more than one field in the table, you will need to use
calculated fields in the query to break it into more than one field then
sort on those fields. Since these fields will be for sorting only, you could
uncheck the "Show" box for these fields in the query design grid. Remove and
sorting you have on the field itself. Let the calculated fields to the
sorting, the field itself though is the one you will display (the "Show" box
will be checked).
For the year field:
YearSort:IIf(Right([FieldName], 2) > 50, Right([FieldName], 2) + 1900,
Right([FieldName], 2) + 2000)
Set Sort to Ascending. If you have years older than 1951 then you will need
to adjust the ">50" portion to the oldest year you have. Without you
supplying 4 digits, an assumption has to be made as to when to assume "19"
and "20" as the first two digits of the year.
For the rest of the sort:
RestSort:Left([FieldName], Len([FieldName])-2)
Set Sort to Ascending. This removes the right two numbers from the end.
Since it uses the Len() function, it will allow for 2 or 3 initials.
Place these two calculated fields in the query with the first one to the
left of the second one. Access will sort the fields in the order listed,
from left to right.
--
Wayne Morgan
MS Access MVP
Dominic Hamblin said:
I would like to sort it by the year firstly and then by the numbers upfront
because every year they start at 0001 so i when i sort i end up getting
0001
then the first set of initials in alphabetical order then the date 00 when
the 1st date inputed should show up as 0001/xx/94