>Hi,
>
>I have a table that contains two fields. One is a unique id and the other is a company name. I also have a form that allows users to add company names to the table. Right now I have code that checks to see if the company has already been entered by comparing the value entered versus the table column for company name. However, this is not very effective. For example, the company name 'Turner Construction' could be in the table and the user enters 'The Turner Construction Company' or some derivative of this and it would not result in a match. Can someone please provide a suggestion on how to better handle this.
Ahh, users - gotta love 'em! I'd suggest fines and/or electric shocks.
Seriously, you have 2 main approaches - you can use either or both.
1. Pre-processing - before a user enters a "new" record, give them an opportunity to look up the entry they're about to make - e.g. a partial string search on "Turner" would probably "turn" it up, so they would know not to even bother entering the "new" entry in the first place.
2. Post-processing - after a user enters a "new" record, make partial string searches on all "meaningful" separate words in the "new" entry. If match(es) are found, display them so the user has a chance to choose an existing one (thereby automatically aborting the "new" entry) or, after confirmation, create the new entry as the user wants.
The second option gets tricky if the user makes spelling mistakes e.g. "Tuner Constructon" could be quite tricky to match to an already-existing record. You might need to look into the VFP SOUNDEX() function or a third-party alternative.
Regards. Al
"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov
Neither a despot, nor a doormat, be
Every app wants to be a database app when it grows up