Hi,
I have two tables and need find create a one to many relationship using the field name of "part number" in each table. Obviously it's very simple if the two fields match. However, because I don't control how the "part number" data is entered in the parent database there may be records in the other data base that "should" match but don't because someone typed in the "part number" a little differently. Unfortunately there is no way to control the inputting of data into that database because I'm actually receiving the data from my customer via an excel spreadsheet. An example of what I might see:
Main Table Child Table
Part Number ABC12ATR ABC12A-TR
or
Part Number STABC12ATR ABC12A-TR
Because I deal with so many customers there is no way to predict how they might enter data into this field. So my thought was to write a query to creates a mid string of the "part number" field in the main table and call it "part number truncated". In the first example above, if my new field pulled in the first 6 characters and I could define the link as a "like" link (i.e. as long as it found those same characters in the second database it would be considered a match - *ABC12A* to ABC12A-TR) then it would find the matching part. It may also find other records too, but as long as I could show all the matches I would then be able to pick the one that best matches the actual part in the first database. There are several more fields in each database, but I don't think that is relative to my question. Is there any way to create that one to many link were it is considered a match as long as the first database is a subset of the second database?
If this is possible in code I have a second question. I could hard code the mid string character count in the query, but I'd rather make it dynamic. The first pass would be to look for perfect matches. The second pass might remover the first 2 and last 2 characters. The user would continue to narrow the main table's part number until it started to find matches or it got so small it didn't makes sense to shorten it any further. FYI, the length of characters in the "part number" field can vary from 3 or 4 up to 15 or 20. I would like to have the operator prompted prior to running the query with the following:
Enter the number of characters you would like to remove from the beginning of the part number string:
Enter the number of characters you would like to leave in the part number string:
Thanks in advance for any guidance anyone can provide. Solving this would be a huge help for me.