Tim said:
I think you'll need something like
Mid$([ItemCode],11,3)
and, if [ItemCode] is in the form of "06-V1T3R4-235-8", it should return
"235" which is what you want.
I don't think we have enough information about the rest of the pattern
to be bale to know we can identify the value to be tested. For example,
Tim's had to assume the 'number' to validate will always start at
position 11.
Although the OP's rule 'second last number' is possible, I suspect it
is not the complete truth either <g>.
Therefore, I'm going to assume the pattern of the hyphens will
determine the position of the 'number'.
Here's a break down of my proposed solution, using the 'ANSI mode'
wildcard character '%'.
Value is between 1 and 9 inclusive:
item_code LIKE '%-%-[1-9]-%'
Value is between 10 and 99 inclusive:
item_code LIKE '%-%-[1-9][0-9]-%'
Value is between 100 and 299 inclusive:
item_code LIKE '%-%-[1-2][0-9][0-9]-%'
Value is between 300 and 359 inclusive:
item_code LIKE '%-%-3[0-5][0-9]-%'
Value is between 360 and 365 inclusive:
item_code LIKE '%-%-36[0-5]-%'
In full:
item_code LIKE '%-%-[1-9]-%'
OR item_code LIKE '%-%-[1-9][0-9]-%'
OR item_code LIKE '%-%-[1-2][0-9][0-9]-%'
OR item_code LIKE '%-%-3[0-5][0-9]-%'
OR item_code LIKE '%-%-36[0-5]-%'
Or to be implementation-indepenedent, as we should always be:
item_code LIKE '%-%-[1-9]-%'
OR item_code LIKE '%-%-[1-9][0-9]-%'
OR item_code LIKE '%-%-[1-2][0-9][0-9]-%'
OR item_code LIKE '%-%-3[0-5][0-9]-%'
OR item_code LIKE '%-%-36[0-5]-%'
OR item_code LIKE '*-*-[1-9]-*'
OR item_code LIKE '*-*-[1-9][0-9]-*'
OR item_code LIKE '*-*-[1-2][0-9][0-9]-*'
OR item_code LIKE '*-*-3[0-5][0-9]-*'
OR item_code LIKE '*-*-36[0-5]-*'
AND item_code <> '%-%-[1-9]-%'
AND item_code <> '%-%-[1-9][0-9]-%'
AND item_code <> '%-%-[1-2][0-9][0-9]-%'
AND item_code <> '%-%-3[0-5][0-9]-%'
AND item_code <> '%-%-36[0-5]-%'
AND item_code <> '*-*-[1-9]-*'
AND item_code <> '*-*-[1-9][0-9]-*'
AND item_code <> '*-*-[1-2][0-9][0-9]-*'
AND item_code <> '*-*-3[0-5][0-9]-*'
AND item_code <> '*-*-36[0-5]-*'
Jamie.
--