tft每日頭條

 > 科技

 > access 使用vba查詢數據如何保存

access 使用vba查詢數據如何保存

科技 更新时间:2024-10-04 05:43:13

access 使用vba查詢數據如何保存?Public filter_text As String '定義為公共變量,今天小編就來聊一聊關于access 使用vba查詢數據如何保存?接下來我們就一起去研究一下吧!

access 使用vba查詢數據如何保存(Access數據庫功能模塊講解)1

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

,

更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!

查看全部

相关科技资讯推荐

热门科技资讯推荐

网友关注

Copyright 2023-2024 - www.tftnews.com All Rights Reserved