>>Hi everyone,
>>
>>In my main table I have 10 character Amenity field. This field could be empty or could be like:
>>
>>AB
>>CD
>>A8BC
>>BCDFJ
>>
>>where each letter is a coded value.
>>In Amenities Lookup table I have each code and its description, like, for instance:
>>(don't show the actual codes)
>>A - Air Conditioned
>>etc.
>>
>>User selects one or multiple codes from multilist:
>>This is the code, I use for creating where expression:
>>
>>
>>* return criterion for field value
>> lnLen=alen(.btcSelArray, 1)
>> for li = 1 to lnLen
>> m.crit=m.crit+ iif(li=1,iif(.ExcludeFlag, '! ', ''),iif(.ExcludeFlag, ' AND ! ', ' OR '))+;
>> '"'+.btcSelArray[li]+'" $ '+mapto
>> endfor
>>
>>
>>My question is: do you think it's the best solution or there is another better solution?
>>
>>Thanks in advance.
>
>Hi Nadya,
>
>Here we go :)
>
>* return criterion for field value
>lnLen=alen(.btcSelArray, 1)
>lcSelList = ""
>for li = 1 to lnLen
> lcSelList = lcSelList + .btcSelArray[li]
>endfor
>
>lcCrit = [ (Not Empty(]+mapto+[) AND Empty( Chrtran(]+mapto+[, Chrtran(mapto, lcSelList, ""), "")) ]
>
Hi again Sergey,
I thought a little bit more, and understood, what you're right and I was wrong in my assumption. I asked my manager, to be sure.
If a person selects 2 or more items, it means, what all items should be found in the same record, so your solution should work.
lcCrit = [(Not Empty(]+mapto+ ;
[) AND Empty(Chrtran(]+mapto+[, Chrtran(]+mapto+[, lcSelList, ""), "")))]
If a person turns on exclusion flag, that means, what he/she doesn't want records, which may contain one of the items, he/she selects.
lcCrit = [(Empty(]+mapto+ ;
[) or Not Empty(Chrtran(]+mapto+[, Chrtran(]+mapto+[, lcSelList, ""), "")))]
??????
If it's not broken, fix it until it is.
My Blog