vba - 访问拆分表单上的多个过滤器中的不同或唯一计数
问题描述
我正在制作一个表格,用于从访问数据表中提取数据。我尝试过滤日期范围、状态、区域、承包商、项目类型之间的数据,以及不同不同字段的总计计算。我写了一些 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
解决方案
推荐阅读
- sas - 连续结果变量(有许多零)和使用 SAS 的预测变量之间的关系
- java - 只有INFO 日志被显示。尽管 chaging log4.properties 调试日志不可见
- c++ - 谁能帮我理解这个错误信息?
- javascript - 数组对象的碰撞检测
- android - How to make set TextView.text persistent in Android app (Kotlin)
- sql - 无法显示区域容量为零
- python - 如何获取图像中的边框像素或擦除区域
- javascript - 按钮提交后如何刷新CSS?
- javascript - 无法使用三元条件读取“未定义”的属性 x?
- javascript - 如何设置跨站点cookies?