首页 > 解决方案 > 访问拆分表单上的多个过滤器中的不同或唯一计数

问题描述

在此处输入图像描述我正在制作一个表格,用于从访问数据表中提取数据。我尝试过滤日期范围、状态、区域、承包商、项目类型之间的数据,以及不同不同字段的总计计算。我写了一些 vba 代码,但没有完全成功。我可以上传我的文件。下面是正常工作的日期范围代码,但如何在此代码中添加其他字段?抱歉我的英语和解释不好。谢谢

Private Sub cmdsearch_Click()

' Search button
Call search
End Sub
'date box
Sub search()
Dim strCriteria As String
Dim task As String
Dim Contractor As String
Me.Refresh
'if date not selected
If IsNull(Me.fromdate) Or IsNull(Me.todate) Then
MsgBox "Please enter the date range", vbInformation, "Date Range Required"
Me.fromdate.SetFocus
Else
'between date filter coding
strCriteria = "([Reply_date] >= #" & Me.fromdate & "# And [Reply_date] <= #" & Me.todate & "#)"
task = "select * from As_built_record where (" & strCriteria & ") order by [Reply_date]"
DoCmd.ApplyFilter task
'for total calcuation coding
Me.texttotal = FindRecordCount(task)
End If
End If
End Sub

Private Sub cmdclear_Click()
'clear button
Dim task As String
Me.fromdate = Null
 Me.todate = ""
 task = "select * from as_built_Record where id is null"
DoCmd.ApplyFilter task
'total calculation coding
Me.texttotal = FindRecordCount(task)
End Sub
Private Sub cmdshowall_Click()
'show all button
Dim task As String '
Me.fromdate = Null
Me.todate = ""
task = "select * from as_built_Record order by [Reply_date]"
 Me.RecordSource = task
 'total calculation coding
 Me.texttotal = FindRecordCount(task)
 End Sub

标签: vbams-accessfiltering

解决方案


推荐阅读