我希望通过我正在使用的MS Access表格获得帮助。 我有四个组合框,希望用来过滤两个列表框。
所有四个列表框都应在四个组合框中的每个更新后更新。
我的问题是我没有得到预期的结果。两个列表框中的数据都不正确,无法正确检测。
vba代码如下:
Option Compare Database
Private Function SearchCriteria()
Dim strHHC, strCode, strFacility, strStaff, strProvider As String
Dim task, task1, strCriteria As String
If IsNull(Me.cboAudStaff) Then
strStaff = "[Staff] like '*'"
Me.lstMembers.Requery
Else
strStaff = "[Staff] like '*" & Me.cboAudStaff.Value & "*'"
Me.lstMembers.Requery
End If
If IsNull(Me.cboCode) Then
strCode = "[Code] like '*'"
Me.lstMembers.Requery
Else
strCode = "[Code] like '*" & Me.cboCode.Value & "*'"
Me.lstMembers.Requery
End If
If IsNull(Me.cboHHC) Then
strHHC = "[HHC] like '*'"
Me.lstMembers.Requery
Else
strHHC = "[HHC] like '*" & Me.cboHHC.Value & "*'"
Me.lstMembers.Requery
End If
If IsNull(Me.cboFacility) Then
strFacility = "[Dx_ProvFacility] like '*'"
Me.lstMembers.Requery
Else
strFacility = "[Dx_ProvFacility] like '*" & Me.cboFacility.Value & "*'"
Me.lstMembers.Requery
End If
If IsNull(Me.lstProviderList) Then
strProvider = "[Dx_Provider] like '*'"
Me.lstMembers.Requery
Else
strProvider = "[Dx_Provider] = '" & Me.lstProviderList.Value & "'"
Me.lstMembers.Requery
End If
strCriteria = strStaff & "And" & strCode & "And" & strHHC & "And" & strFacility & "And" & strProvider
'task = "SELECT * FROM lstAssignedList where" & strCriteria
'Me.lstAssignedList_subform.Form.RecordSource = task
'Me.lstAssignedList_subform.Form.Requery
task = "SELECT * FROM vProvider_Stat_List where" & strCriteria
Me.lstProviderList.RowSource = task
Me.lstProviderList.Requery
End Function
如果可能,请提供帮助。
] 1