access数据库(access数据库导入excel表格)

前沿拓展:

access数据库

数据库,顾名思义:数据的仓库。
当使用者需要保存的数据量不是很大时,我们可以直接将数据写到编辑完全可视化,且内置强大的Office编程环境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

拓展知识:

前沿拓展:

access数据库

数据库,顾名思义:数据的仓库。
当使用者需要保存的数据量不是很大时,我们可以直接将数据写到编辑完全可视化,且内置强大的Office编程环境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

拓展知识:

原创文章,作者:九贤生活小编,如若转载,请注明出处:http://www.wangguangwei.com/37974.html