例如我可以在两个TEXT控件中输入各一个关键字
也可是只在其中一个TEXT控件中输入关键字
进行查找

解决方案 »

  1.   

    sql="select * from table where col like '%"+text1.text+"%' and col like '%"+text2.text +"%'"
      

  2.   

    自己构造Where语句sql="select * from table where 1=1"
    if trim(text1.text)<>"" and trim(text2.text)<>"" then
       sql=sql & " and col1='" & text1.text & "' and col1='" & text2.text & "'"
    else
    .....................
    end if
      

  3.   

    sql="select * from table where 1=1"
    if trim(text1.text)<>""  then
       sql=sql & " and col1='" & text1.text & "'"
    end if
    if trim(text2.text)<>"" then
      sql=sql & " and col2='" & text2.text & "'"
    end ifcn.execute sql
      

  4.   

    sql="select * from table where 1=1"
    if trim(text1.text)<>""  then
       sql=sql & " and col1='" & text1.text & "'"
    end if
    if trim(text2.text)<>"" then
      sql=sql & " and col2='" & text2.text & "'"
    end ifcn.execute sql