Search Form

I'm using the QBF solution form that is with VFP 9.0. How can I make it so that the search doesn't need to be case sensitive If I want to search for David, I want my users to be able to type in david & still find that record.


Answer this question

Search Form

  • Gary Nicol

    Ok thanks!!!  Do I put "cSearch = UPPER(cSearch)" in the click event of my search command button  

    Here is my code for my search command button:


    New" color="#0000ff" size="2">

    LOCAL New" size="2">cFilter

    cFilter = ""

    New" color="#0000ff" size="2">

    FOR New" size="2">nCnt = 1 New" color="#0000ff" size="2">to THISFORMNew" size="2">.New" color="#0000ff" size="2">ControlCount

    IF TYPENew" size="2">('THISFORM.Controls(nCnt).controlSource') <> "U" THEN

    IF !EMPTY(THISFORM.Controls(nCnt).ControlSource) AND ;

    TYPE('THISFORM.Controls(nCnt).value') <> "U" THEN

    cCondition = THISFORM.parseCondition(THISFORM.Controls(nCnt).value,THISFORM.Controls(nCnt).controlSource)

    IF !EMPTY(cCondition) THEN

    cFilter = cFilter + " AND " + cCondition

    ENDIF

    ENDIF

    ENDIF

    ENDFOR

    ROLLBACK

    THIS.Enabled = .F.

    THISFORM.cmdQBFMode.Enabled = .T.

    THISFORM.txtEmp_ID.readonly = .T.

    IF !EMPTY(cFilter) THEN

    cFilter = ALLTRIM(SUBSTRC(cFilter,5))

    ENDIF

    SET FILTER TO &cFilter

    THISFORM.cmdClearFilter.enabled = .T.

    THISFORM.vcr1.enabled = .T.

    THISFORM.vcr1.cmdTop.click

    THISFORM.Refresh


     

  • Chien-hao Wesley Wen

    You could do that. Basically in your example you could UPPER() the search string in your cCondition variable, or in whatever the ParseCondition()  method returns.

  • gimo

    The way to do case-insensitive searches is to convert all to one case.

    Index your key field in UPPER(fieldname). Then convert your search string to uppercase behind the scenes.

    cSearch = UPPER(cSearch)     && "David" gets converted to "DAVID"

    Then you search in all uppercase.


  • Search Form