有4个文本框:文章编号txt_id, 标题txt_title, 作者txt_author, 出处txt_from
做个查询,当输入为空,显示全部记录,当任意输入其中的文本框,显示出符合条件的记录,怎么做?
请高手指点,谢谢!

解决方案 »

  1.   

    dim wherstr as string
    dim strsql as string if len(txt_id)>0 then  wherestr=wherestr & "id='" & txt_id & "' and "
    if len(txt_title)>0 then  wherestr=wherestr & "title=' and " & txt_title& "'"
    if len(txt_author)>0 then  wherestr=wherestr & "author=' and " & txt_author& "'"
    if len(txt_from)>0 then  wherestr=wherestr & "from='" & txt_from& "' and "if len(wherestr)>0 then
        wherestr=" where " & left$(wherestr,len(wherestr)-4))
    end ifstrsql="select * from [youtable] " & wherestr
      

  2.   

    还有其它做法吗?谢谢 MSTOP(陈建华(东莞立晨企业资讯服务有限公司))
      

  3.   

    谁能帮我看看
    http://www.5ivb.net/club/vbupload/hooligan_vb.rar
    谢谢了
      

  4.   

    建议在表中多设一个自动ID,然后strsql="select * from [youtable] " & wherestr & "order by 自动ID asc"。先记下当前显示记录的自动ID,如mRemID = mRst("自动ID"),按“上一条记录”时就 "select * from (" & strsql & ") where 自动ID < " & cStr(mRemID)
    按“下一条记录”时就 "select * from (" & strsql & ") where 自动ID > " & cStr(mRemID)最后记得把当前显示记录的自动ID赋值给mRemID