IF NOT EMPTY(THIS.PARENT.C40txtDocNomen.VALUE) llCriteriaEntered = .T. LOCAL lcDocValue lcDocValue = ALLTRIM(THIS.PARENT.C40txtDocNomen.VALUE) IF AT_C('*',lcDocValue,1) = 0 * The user entered a search with no wild card characters lcFilter = lcFilter + ' AND docNomen = "'+ lcDocValue +'"' ENDIF IF LEN(lcDocValue) = AT_C('*',lcDocValue,1) * The user entered a wildcard in last position, so lets remove it and set the filter lcDocValue = SUBSTR(lcDocValue,1,LEN(lcDocValue)-1) lcFilter = lcFilter + ' AND docNomen = "'+ lcDocValue +'"' ENDIF IF AT_C('*',lcDocValue,1) > 0 AND AT_C('*',lcDocValue,2) > 0 * The user entered 2 wildcard search characters so they wish to perform a contains search * lets remove the wildcard characters and set the filter lcDocValue = STRTRAN(lcDocValue,'*','') lcFilter = lcFilter + ' AND "'+ lcDocValue +'" $ docNomen' ENDIF IF AT_C('*',lcDocValue,1) = 1 AND AT_C('*',lcDocValue,2) = 0 * The user entered a wildcard at the start only * so this would be treated as a contains also lcDocValue = STRTRAN(lcDocValue,'*','') lcFilter = lcFilter + ' AND "'+ lcDocValue +'" $ docNomen' ENDIF ENDIFI also have used an SQL query using the LIKE operator to get my records into a cursor. LIKE %lcValueEntered%
DO CASE CASE OCCURS('*',mlotnumber) = 0 mwhere = mwhere + 'AND LOTLOTCARD.LOTNUMBER = "'+(mlotnumber)+'" ' CASE (OCCURS('*',mlotnumber) = 1) AND (LEN(mlotnumber) = AT('*',mlotnumber)) mchop = AT('*',mlotnumber) - 1 mlotnumber = SUBSTR(mlotnumber,1,mchop) mwhere = mwhere + 'AND LOTLOTCARD.LOTNUMBER = "'+(mlotnumber)+'" ' OTHERWISE mlotnumber = CHRTRAN(mlotnumber,'*','%') mwhere = mwhere + 'AND LOTLOTCARD.LOTNUMBER LIKE "'+(mlotnumber)+'" ' mhardsrch = .T. ENDCASE