Because if the user is searching on last name ONLY. If he/she enters from smith to smith then it should include SMITH III*JAMES and it does. I'll try your code too. The code I modified from Elmer is working.
>Hi Tracy,
>
>Try this. Should work with EXACT OFF as well.
>
>Mike
>
>BTW Why are you replacing your spaces with * ? It will mess up "SMITH III*MICHAEL"
>
>
>xreturn=.T.
>IF !EMPTY(xfrom) OR !EMPTY(xto)
> xfrom=ALLTRIM(UPPER(xfrom))
> xto=ALLTRIM(UPPER(xto))
> lcInsName=UPPER(STRTRAN(insured.po_name," ","*",1))
> lnPos=AT("*",lcInsName)-1
> IF xfrom==xto
> IF xfrom==LEFT(lcInsName,lnPos)
> ? po_name+ " YES a match"
> xreturn = .T.
> ELSE
> ? po_name+" NO not a match"
> xreturn = .F.
> ENDIF
> ELSE
> *--TCH 08/13/2003 * for SMITH III*JAMES, etc
> *IF !BETWEEN(UPPER(LEFT(insured.po_name, ;
> * AT("*",insured.po_name)-1)),xfrom,xto)
> IF !BETWEEN(LEFT(lcInsName,lnPos),xfrom,xto)
> xreturn = .F.
> ENDIF
> ENDIF
>ENDIF
>
>
>
>>We are searching records for any condition using a from and to condition. Records are stored like so:
>>
>>SMITH*JAMES
>>SMITH III*MICHAEL
>>SMITH JR*JOHN
>>SMITHERMAN*PETER
>>
>>I must account for the user entering from: SA to: SMITH or from: SMITH to: SMITH, or from: A to: Z, etc. SMITH to SMITH should NOT include SMITHERMAN...
>>
>>The below code works (If exact is on and near is off), but can it be faster?
>>
.·*´¨)
.·`TCH
(..·*
010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"