Access2016-VBA代码-过滤器-多个条件-无法工作

Access2016-VBA代码-过滤器-多个条件-无法工作,vba,ms-access-2016,Vba,Ms Access 2016,我有一个带有组合框的主窗体来过滤子窗体 我希望根据组合框中的条目筛选子窗体中的信息 就我的生命而言,我无法让它工作: Private Sub CMBOwner_AfterUpdate() Dim strWhere As String Dim lngLen As Long strWhere = "" 'Look at each search box, and build up the criteria string from the non-blank ones. 'Loca

我有一个带有组合框的主窗体来过滤子窗体

我希望根据组合框中的条目筛选子窗体中的信息

就我的生命而言,我无法让它工作:

Private Sub CMBOwner_AfterUpdate()
Dim strWhere As String
Dim lngLen As Long
strWhere = ""

'Look at each search box, and build up the criteria string from the non-blank ones.
'LocationName Field
If Not IsNull(Me.CMBLocationID) Then
     strWhere = strWhere & "[InventoryLocationID] = " & Me.CMBLocationID
     Else
     strWhere = strWhere & "[InventoryLocationID] = '" & "'"
End If

'Owner Field
If Not IsNull(Me.CMBOwner) Then
        If strWhere <> "" Then
        strWhere = strWhere & " AND [fkOwner] = " & Me.CMBOwner
        Else
        strWhere = strWhere & "[fkOwner] = " & Me.CMBOwner
        End If
End If


'SupplyName Field
If Not IsNull(Me.CMBAssetName) Then
        If strWhere <> "" Then
        strWhere = strWhere & " AND [fkSupplyID] = " & Me.CMBAssetName
        Else
        strWhere = strWhere & "[fkSupplyID] = " & Me.CMBAssetName
        End If
End If



If Len(strWhere) <= 0 Then 'There was nothing in the string
    Exit Sub
Else 'There is something , so remove "AND" at the end.
    'For debugging, remove the leading quote on the next line.  Prints to Imediate Window (Ctrl+G)
Debug.Print strWhere

    'Finally, apply the string as the form's Filter.
[Forms]![FrmTransSupplySummary]![QrySupplyTransDS].Form.Filter = strWhere
[Forms]![FrmTransSupplySummary]![QrySupplyTransDS].Form.FilterOn = True
End If

End Sub
Private Sub-CMBOwner\u AfterUpdate()
作为字符串的Dim strWhere
幽幽幽幽
strWhere=“”
'查看每个搜索框,并从非空的搜索框中建立条件字符串。
'LocationName字段
如果不为null(Me.CMBLocationID),则
strWhere=strWhere&“[InventoryLocationID]=”&Me.CMBLocationID
其他的
strWhere=strWhere&“[InventoryLocationID]=”&“”
如果结束
'所有者字段
如果不为空(Me.CMBOwner),则
如果这里是“”,那么
strWhere=strWhere&“和[fkOwner]=”&Me.CMBOwner
其他的
strWhere=strWhere&“[fkOwner]=”&Me.CMBOwner
如果结束
如果结束
'SupplyName字段
如果不为null(Me.CMBAssetName),则
如果这里是“”,那么
strWhere=strWhere&“和[fkSupplyID]=”&Me.CMBAssetName
其他的
strWhere=strWhere&“[fkSupplyID]=”&Me.CMBAssetName
如果结束
如果结束

如果我能解决我自己的问题。一旦我在清除或窗体打开时将值设置为NULL,这个公式就像做梦一样工作。