If comXM.Text = "" Or txtCZ.Text = "" Then
  sql = "select * from wxb ORDER BY wgrq"
Else
Dim xmmc As String '项目名称
   If Me.comXM.Text = "维修单号" Then xmmc = "wxid"
   If Me.comXM.Text = "报修人" Then xmmc = "bxr"
   If Me.comXM.Text = "完工日期" Then xmmc = "wgrq"
   If Me.comXM.Text = "服务类型" Then xmmc = "fwlx"
   If Me.comXM.Text = "服务方式" Then xmmc = "fwfs"
   If Me.comXM.Text = "维修人员" Then xmmc = "wxry"  sql = "select * from wxb where " & xmmc & " like '%" & txtCZ.Text & "%'and (wgrq> '%" & Text1.Text & "%'and wgrq< '%" & Text2.Text & "%' )"
End If其中Text1.Text开始日期  Text2.Text 为结束日期

解决方案 »

  1.   

    sql = "select * from wxb where " & xmmc & " like '%" & txtCZ.Text & "%' and (wgrq> '" & Text1.Text & "' and wgrq< '" & Text2.Text & "' )"  
    *****************************************************************************
    欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) 最新版本:20070130http://www.cnblogs.com/feiyun0112/archive/2006/09/20/509783.html
      

  2.   

    If Me.comXM.Text = "维修单号" Then xmmc = "wxid"
       If Me.comXM.Text = "报修人" Then xmmc = "bxr"
       If Me.comXM.Text = "完工日期" Then xmmc = "wgrq"
       If Me.comXM.Text = "服务类型" Then xmmc = "fwlx"
       If Me.comXM.Text = "服务方式" Then xmmc = "fwfs"
       If Me.comXM.Text = "维修人员" Then xmmc = "wxry"
    这里可以改成select case来写然后
    sql = "select * from wxb where " & xmmc & " like '%" & txtCZ.Text & "%' and (wgrq> '" & Text1.Text & "' and wgrq< '" & Text2.Text & "' )"