access 使用vba查询数据如何保存(Access数据库功能模块讲解)

Public filter_text As String '定义为公共变量,今天小编就来聊一聊关于access 使用vba查询数据如何保存?接下来我们就一起去研究一下吧!

access 使用vba查询数据如何保存(Access数据库功能模块讲解)

access 使用vba查询数据如何保存

Public filter_text As String '定义为公共变量

Private Sub Command查询_Click()

filter_text = ""

If Me.员工编号 <> "" Then

If filter_text <> "" Then

filter_text = filter_text & " and 员工编号 like '*" & Me.员工编号 & "*'"

Else

filter_text = "员工编号 like '*" & Me.员工编号 & "*'"

End If

End If

If Me.部门 <> "" Then

If filter_text <> "" Then

filter_text = filter_text & " and 部门 like '*" & Me.部门 & "*'"

Else

filter_text = "部门 like '*" & Me.部门 & "*'"

End If

End If

If Me.职位 <> "" Then

If filter_text <> "" Then

filter_text = filter_text & " and 职位 like '*" & Me.职位 & "*'"

Else

filter_text = "职位 like '*" & Me.职位 & "*'"

End If

End If

If Me.姓名 <> "" Then

If filter_text <> "" Then

filter_text = filter_text & " and 姓名 like '*" & Me.姓名 & "*'"

Else

filter_text = "姓名 like '*" & Me.姓名 & "*'"

End If

End If

If Me.销售日期1 <> "" And Me.销售日期2 <> "" Then

If filter_text <> "" Then

filter_text = filter_text & " and 销售日期 between #" & Me.销售日期1 & "# and #" & Me.销售日期2 & "#"

Else

filter_text = "销售日期 between #" & Me.销售日期1 & "# and #" & Me.销售日期2 & "#"

End If

End If

If Me.销售额1 <> "" And Me.销售额2 <> "" Then

If filter_text <> "" Then

filter_text = filter_text & " and 销售额 >= " & Me.销售额1 & " and 销售额<=" & Me.销售额2

Else

filter_text = "销售额 >= " & Me.销售额1 & " and 销售额<=" & Me.销售额2

End If

End If

'------------------------------筛选子窗体

If filter_text <> "" Then

Me.数据表子窗体.Form.Filter = filter_text

Me.数据表子窗体.Form.FilterOn = True

Else

Me.数据表子窗体.Form.FilterOn = False

End If

End Sub

Private Sub Command清空_Click()

员工编号.Value = ""

姓名.Value = ""

部门.Value = ""

职位.Value = ""

销售日期1.Value = ""

销售日期2.Value = ""

销售额1.Value = ""

销售额2.Value = ""

End Sub

Private Sub Command全部_Click()

Me.数据表子窗体.Form.FilterOn = False

End Sub

,

免责声明:本文仅代表文章作者的个人观点,与本站无关。其原创性、真实性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容文字的真实性、完整性和原创性本站不作任何保证或承诺,请读者仅作参考,并自行核实相关内容。文章投诉邮箱:anhduc.ph@yahoo.com

    分享
    投诉
    首页