I have a name field that can contain more than one name, the names are always separated by “and” (i.e. Thomas S. Smith and Tracey L. Smith). I need to split these names out to separate names on certain forms.
I started with this code:
If InStr(ucName, " and ") Then
ucBuy1 = Left(ucName, InStr(ucName, " and ") - 1)
ucBuy2 = Right(ucName, InStr(ucName, " and ") - 1)
This works some of the time, but there is inconsistency in the results. Sometimes the first few letters are cut from the second name, other times the word “and” is included in the second name.
Is there an easy way to solve this problem?
Thanks in advance.
Bill
I started with this code:
If InStr(ucName, " and ") Then
ucBuy1 = Left(ucName, InStr(ucName, " and ") - 1)
ucBuy2 = Right(ucName, InStr(ucName, " and ") - 1)
This works some of the time, but there is inconsistency in the results. Sometimes the first few letters are cut from the second name, other times the word “and” is included in the second name.
Is there an easy way to solve this problem?
Thanks in advance.
Bill