John,
Thank you for your response. There will never be more than 1 letter and most
of the time there will only be numbers. I have put the iff statement in the
criteria and changed the "MyField" to Sheet, when I run the query it says it
is to complex. Attached is the SQL Stement:
SELECT tblPartNumber.Part, tblPartNumber.Sheet, tblPartNumber.Title,
tblPartNumber.Reference, tblPartNumber.Type, tblPartNumber.Sheet AS Sort
FROM tblPartNumber
WHERE (((tblPartNumber.Part) Like [Enter Number+Alpha*]) AND
((tblPartNumber.Sheet)=IIf([Sheet] Like
"[!0-9]*",Val(Mid([Sheet],2)),Val([Sheet]))));
I have also been trying:
Right([Sheet],3) in the criterial, but this only sorts by the 1st digit so 4
could be after 39.
Am I missing something?
Thanks again for your assistance.
Tim Peter
John Spencer said:
Ok, if you never have more than one letter character then you can use an
expression like this to get the numeric value and then sort by this caclulated
field.
Field: NumberSort: IIF([MyField] Like "[!0-9]*", Val(Mid([MyField],2)),
Val([MyField]))
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
tpeter wrote:
What I am attempting to do is when it sorts the field in assending order if
there is a letter, ignore the letter and sort by the numbers, if there is no
letter before the numbers sort them as numbers. I am unable to make this into
two fields because of company formatting.
:
I have a field that is forced to be a text field. The field is called [sheet]
and contains numbers. This format can vary from 1 to J256. When I run my
query I am unable to sort the data by sheet because it doesn't recognize it
as a number(because of the occational letter). Is there something I can put
into the criterial area that will make it sort in assending order? The
problem is sometimes there is a letter in from of the number and sometimes
not. Thank you for your help, it is greatly appreciated.
Tim Peter