所以我在MS Access中创建了一个缺陷数据库,我正在编写一个搜索表单,以查找特定日期之间的特定员工缺陷。我已经使用按钮进行日期范围搜索,但我还没想出如何将EmployeeNameBox添加到过滤器结果中。这就是我所拥有的。
Private Sub Searchbtn_Click()
Me.Filter = "[DayMonthYear] BETWEEN #" & Me.Date1Filt & "# AND #" & Me.Date2Filt & "#"
Me.FilterOn = True
End Sub
适用于我想要的日期范围,但我还需要添加员工姓名。任何帮助将非常感激。
假设您的EmployeeNameBox
将始终在搜索时填充,您只需将其添加到您的过滤器。我发现将过滤器存储在变量中更容易,然后在最后将其分配给Me.Filter
。所以类似于:
Private Sub Searchbtn_Click()
Dim sFilter as String
sFilter = _
"[DayMonthYear] BETWEEN " & _
"#" & Me.Date1Filt & "# AND " & _
"#" & Me.Date2Filt & "# " & _
" AND [EmployeeName] = """ & Me.EmployeeNameBox & """"
Me.Filter = sFilter
Me.FilterOn = True
End Sub