常规查询条件
   部门__________
   岗位__________
   雇佣性质_______
   编号_____         姓名_____          性别______
   学历_____
其他查询条件(3个条件,前边有个复选框,可以选择用那几个!)
   年龄(是个下拉列表框,能列出表中所有的字段,选哪个就用哪个查询 ,年龄是其中一个) 介与_______ 与________间
   员工类别(是个下拉列表框,能列出表中所有的字段,选哪个就用哪个查询,员工类别是其中一个 )___________
   出生年月(是个下拉列表框,能列出表中所有的字段,选哪个就用哪个查询,民族是其中一个  )  > __________后
   
    如何做这样一个查询?查询是在一个表中进行,如何把 常规查询和其他查询条件写上去??用一个查询语句   

解决方案 »

  1.   

    呵呵,给你点建议,使用recordset的Filter功能
      

  2.   

    先全部查询出,然后使用Filter设置条件就好了,给分吧,嘿嘿
      

  3.   

    那么心急啊,我到还没用过filter呢?怎么写不妨给个代码?谢谢了,一定给分
      

  4.   

    呵呵,例如:recordset.filter="出生年月>'2000'"
      

  5.   

    选出值放到比如strField    " & strfield & " = '" & strvalue & "' "
      

  6.   

    判断啊,例如:recordset.filter="出生年月>'"+text1.text+"'"当然,你要先对text1.text进行异常处理这样说明白了吧
      

  7.   

    给你看看我怎样做组合查询的 
     SQL = ""
    If Check1.Value = 1 Then
        SQL = SQL & " and  size like '" & Trim(Text1) & "' "
    End IfIf Check2.Value = 1 Then
        SQL = SQL & " and  jsr='" & Trim(Text2) & "' "
    End IfIf Check3.Value = 1 Then
        SQL = SQL & " and  zb='" & Trim(Text3) & "' "
    End IfIf Check5.Value = 1 Then
        SQL = SQL & " and  coninv like '" & Trim(Text4) & "' "
    End IfIf Check8.Value = 1 Then
        SQL = SQL & " and  dwbh ='" & Trim(Text7) & "' "
    End If
    If Check10.Value = 1 Then
        SQL = SQL & " and  ck ='" & Trim(Combo1) & "' "
    End If
    If Option1.Value = True Then
        SQL = SQL & " and inout='出库' "
    End IfIf Option2.Value = True Then
        SQL = SQL & " and inout='入库' "
    End If
    '验收情况If Option6.Value = True Then
        SQL = SQL & " and ( not  (ysr is null or rtrim(ysr)='')) "
    End IfIf Option5.Value = True Then
        SQL = SQL & " and (ysr is null or rtrim(ysr)='') "
    End IfIf Check4.Value = 1 Then
        SQL = SQL & " and rq>='" & Format(rq1, "yyyy-MM-dd") & "' " & " and rq<='" & Format(rq2, "yyyy-MM-dd") & "' "End IfIf Check9.Value = 1 Then
        SQL = SQL & " and YSrq>='" & Format(YSrq1, "yyyy-MM-dd") & "' " & " and YSrq<='" & Format(ySRQ2, "yyyy-MM-dd") & "' "End IfIf Check6.Value = 1 Then
        If Len(Text5) < 6 Then
            On Error Resume Next
            Text5 = Format(CDbl(Text5), "000000")
            On Error GoTo 0
        End If
        SQL = SQL & " and inno like '" & Text5 & "'"End IfIf Check11.Value = 1 Then
        SQL = SQL & " and kw like '" & Me.Text8 & "' "
        If Option9.Value = True Then
            SQL = SQL & " and ckbj<>'1' "
        End If
        
    End If
    If SQL = "" Then
        MsgBox "至少输入一个条件吧!"
        Exit Sub
    End If
        SQL = "select * from tabinout where 1=1  " & SQL
        SQL = SQL & "  order by  idd"r.Open SQL, cN
      

  8.   

    sql=""
    sql=sql & "select 部门" & vbnewline
    sql=sql & "      ,岗位 " & vbnewline
    ………………
    sql=sql & "  from 表 " & vbnewline
    sql=sql & " where " & strfield1 & " between '" & strvalue11 & "' and '" & strvalue12 & "' "  & vbnewline
    sql=sql & "   and " & strfield2 & " = '" & strvalue2 & "'  "  & vbnewline
    ………………
      

  9.   

    谢谢tongnaifu 不过我还不是很明白,我能给你发个界面吗!你看看具体如何实现!能给我你的qq,或email吗?
      

  10.   

    从list选出值放到比如strField可以实现灵活查询
     
    sql="" 
    sql=sql & "select 部门" & vbnewline 
    sql=sql & "      ,岗位 " & vbnewline 
    ……………… 
    sql=sql & "  from 表 " & vbnewline 
    sql=sql & " where " & strfield1 & " between '" & strvalue11 & "' and '" & strvalue12 & "' "  & vbnewline 
    sql=sql & "  and " & strfield2 & " = '" & strvalue2 & "'  "  & vbnewline 
    ………………