I have a table of criteria, one field of which contains part numbers, these can be any length from 1 character up.
The lower the number of characters, the broader the range of items the part applies to. For example:
This was created before my time and just looks for exact matches on part numbers.
Where I'm getting stuck is adapting it to include partial part matches. For example:
User enters 12345. I need to return any parts starting with 1, 12, 123, 1234 and 12345 but not 12346, 12347, etc.
I'm trying to picture a way to take into account the length of the entered value when checking for matches.
Something like "If the length = 5, check for a match on the first 4 characters but exclude anything where the full 5 don't match, then add those where the first three match but exclude anything where the first four don't, and so on"
This feels like it should be easy and, I'm sure, many will read it and wonder why it's even a problem, however it has me stuck.
The lower the number of characters, the broader the range of items the part applies to. For example:
- 12345 might be a specific part from a machine
- Parts starting with 1234 might mean all parts in the left, front, top side of a machine
- Parts starting with 123 might mean all parts in the left, front side of the machine
- Parts starting with 12 might mean all parts in the left side of the machine
- Parts starting with 1 might mean all parts in the machine
This was created before my time and just looks for exact matches on part numbers.
Where I'm getting stuck is adapting it to include partial part matches. For example:
User enters 12345. I need to return any parts starting with 1, 12, 123, 1234 and 12345 but not 12346, 12347, etc.
I'm trying to picture a way to take into account the length of the entered value when checking for matches.
Something like "If the length = 5, check for a match on the first 4 characters but exclude anything where the full 5 don't match, then add those where the first three match but exclude anything where the first four don't, and so on"
This feels like it should be easy and, I'm sure, many will read it and wonder why it's even a problem, however it has me stuck.