在我的查询中,我有一个包含多个名称的字段。有些是经理,有些是审计师。
是我的vba代码,但它不起作用,
Private Sub cboAuditor_AfterUpdate()
strManagers = "<>'Steven' And <>'Lisa' And <>'Christopher' And <>'Ronda' "
strAuditors = "'Steven' Or 'Lisa' Or 'Christopher' Or 'Ronda' Or 'Amber'"
If Me.cboAuditor = "Managers" Then
strAnalystFilter = "[Created By] = '" & strManagers & "'"
ElseIf Me.cboAuditor = "Auditors" Then
strAnalystFilter = "[Created By] = '" & strAuditors & "'"
End If
End Sub
答案 0 :(得分:0)
您无法使用该语法 - 您希望包含与否的人不清楚。但尝试这个开始然后修改:
Private Sub cboAuditor_AfterUpdate()
strManagers = "'Steven','Lisa','Christopher','Ronda'"
strAuditors = "'Steven','Lisa','Christopher','Ronda','Amber')"
If Me.cboAuditor = "Managers" Then
strAnalystFilter = "[Created By] Not In (" & strManagers & ")"
ElseIf Me.cboAuditor = "Auditors" Then
strAnalystFilter = "[Created By] In (" & strAuditors & ")"
End If
End Sub