******************************************************************** * Description.......: BTCC_group.BTC_WherExp: obtain the search expression for this criterion * Calling Samples...: * Parameter List....: mapto_arg * Created by........: * Modified by.......: Nadya Nosonovsky 09/29/2000 03:21:53 PM ******************************************************************** * This function returns a single piece of the search criteria, or empty string if nothing selected. lparameters mapto_arg, tcQueryType, tnMaxLen, tnNumCrit, tlShowCrit * takes 5 optional arguments * mapto_arg: optional alias.fieldname mapping to use in resulting expression. * If omitted or empty, the mapping is determined by the array * property, btcmaparray, for the current query type. local lcCrit, lcRetValue, lnSel, i, lnCodes, mapto if vartype(m.gcTempPath)<>"C" && Variable is not yet defined public gcTempPath gcTempPath=addbs(sys(2023)) endif with this mapto=iif(empty(m.mapto_arg), .btcMapArray[thisform.btcQTmappingNum], m.mapto_arg) if empty(m.mapto) && empty for this Query Type && or control is not visible lcRetValue='' return m.lcRetValue endif lcCrit = .BTC_ItemList() && get the list of selected items if empty(m.lcCrit) && no explicit selection was made lcRetValue='' && null criterion result else lnCodes=.nSelects if empty(m.lnCodes) lnCodes=occurs(',',m.lcCrit)+1 && Number of commas within crit endif do case case m.lnCodes=1 && only one value lcRetValue= m.mapto+iif(.ExcludeFlag,'<>','=') + m.lcCrit case m.lnCodes<=24 and m.lnCodes < .nMaxSelects && INLIST function is limited by 24 codes * return INLIST() criterion for field value in an enumerated list lcRetValue= iif(.ExcludeFlag,'!','')+'INLIST(' + m.mapto + ',' + m.lcCrit + ')' case m.lnCodes>24 and m.lnCodes< .nMaxSelects * Temproraly solution - breaks on the several INLISTs lcCrit='' lcRetValue='' for i=1 to m.lnCodes lcCrit=m.lcCrit+'"'+.btcSelArray[i]+'"'+iif(mod(m.i,24)=0 or m.i=m.lnCodes,'',',') if mod(m.i,24)=0 lcRetValue=m.lcRetValue + ; iif(m.i>24,iif(.ExcludeFlag,' and not',' or'),iif(.ExcludeFlag,'not','')) + ; ' INLIST(' + m.mapto + ',' + m.lcCrit + ')' lcCrit='' && Start a new loop endif next if !empty(m.lcCrit) && Remainder lcRetValue=m.lcRetValue + iif(.ExcludeFlag,' and not',' or') + ; ' INLIST(' + m.mapto + ',' + m.lcCrit + ')' endif lcRetValue='('+alltrim(m.lcRetValue)+')' && Surrounded by () case m.lnCodes >= .nMaxSelects local lcTempName lcTempName='btc'+proper(substr(m.mapto,rat('.',m.mapto)+1)) .btcJoinExp=' INNER JOIN ' + m.gcTempPath + .TableName+' ' + ; m.lcTempName+' ON '+ m.mapto + '='+m.lcTempName+'.BtcCode' lcRetValue=m.mapto + iif(.ExcludeFlag,' NOT','') + ; ' IN ('+m.lcCrit+')' if m.tlShowCrit tnMaxLen=max(m.tnMaxLen,len(m.lcCrit)) && Calculate max length tnNumCrit=m.tnNumCrit+round(len(m.lcCrit)/100,0)+1 && Increment number of strings endif endcase endif endwith return m.lcRetValue>Hi All,