当前位置: 代码迷 >> Access >> access vba之子窗体数据淘选
  详细解决方案

access vba之子窗体数据淘选

热度:9410   发布时间:2013-02-26 00:00:00.0
access vba之子窗体数据筛选
Private Sub query_btn_Click()  querycondition = querycon()  queryresult.Form.FilterOn = False  queryresult.Requery  If Trim(querycondition) <> "" Then    queryresult.Form.Filter = querycondition    queryresult.Form.FilterOn = True  End IfEnd Sub

?其中querycon用于生成查询(筛选)条件,并返回

?queryresult.Form.FilterOn表示筛选器的开关

?queryresult.Form.Filter表示筛选器的条件

?

querycon的大致语句如下:

 strcondition = ""  If Trim(序号) <> "" Then     If Trim(strcondition) <> "" Then        strcondition = strcondition & " and "     End If     strcondition = strcondition & "序号=" & 序号  End If  If Trim(名称) <> "" Then     If Trim(strcondition) <> "" Then        strcondition = strcondition & " and "     End If     strcondition = strcondition & "名称 like '*" & 名称 & "*'"  End If  If Trim(代码) <> "" Then     If Trim(strcondition) <> "" Then        strcondition = strcondition & " and "     End If     strcondition = strcondition & "代码 ='" & 管理代码 & "'"  End If  If Trim(科室名称) <> "" Then        If Trim(strcondition) <> "" Then        strcondition = strcondition & " and "     End If     strcondition = strcondition & "科室名称 like '*" & 科室名称 & "*'"  End If  If Trim(姓名) <> "" Then     If Trim(strcondition) <> "" Then        strcondition = strcondition & " and "     End If     strcondition = strcondition & "姓名 like  '*" & 姓名 & "*'"  End If   If Trim(地址) <> "" Then     If Trim(strcondition) <> "" Then        strcondition = strcondition & " and "     End If     strcondition = strcondition & "地址 like '*" & 地址 & "*'"  End If  querycon = strcondition

?

?

?

根据以上代码?可制作以下窗体,实现access的多参数查询



?

?

?

  相关解决方案