以下是列表中【查询】按钮的代码:
Dim Filter As String
With e.Form.Controls("模糊条件")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " OR "
End If
Filter = Filter & "LCMC like '*" & .Value & "*'"
End If
End With
With e.Form.Controls("DateTimePicker1")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "RQ >= #" & .Value & "#"
End If
End With
With e.Form.Controls("DateTimePicker2")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "RQ <= #" & .Value & "#"
End If
End With
With e.Form.Controls("模糊条件")
If .Value IsNot Nothing Then
Filter = "KHBM like '*" & .Value & "*'"
End If
End With
With e.Form.Controls("模糊条件")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " OR "
End If
Filter = Filter & "KHMC like '*" & .Value & "*'"
End If
End With
With e.Form.Controls("模糊条件")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " OR "
End If
Filter = Filter & "LXR like '*" & .Value & "*'"
End If
End With
With e.Form.Controls("模糊条件")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " OR "
End If
Filter = Filter & "LXDH like '*" & .Value & "*'"
End If
End With
With e.Form.Controls("模糊条件")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " OR "
End If
Filter = Filter & "SHDZ like '*" & .Value & "*'"
End If
End With
With e.Form.Controls("模糊条件")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " OR "
End If
Filter = Filter & "SSXQ like '*" & .Value & "*'"
End If
End With
With e.Form.Controls("模糊条件")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " OR "
End If
Filter = Filter & "XSQD like '*" & .Value & "*'"
End If
End With
With e.Form.Controls("模糊条件")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " OR "
End If
Filter = Filter & "KHDJ like '*" & .Value & "*'"
End If
End With
With e.Form.Controls("模糊条件")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " OR "
End If
Filter = Filter & "BBBM like '*" & .Value & "*'"
End If
End With
With e.Form.Controls("模糊条件")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " OR "
End If
Filter = Filter & "BBYWY like '*" & .Value & "*'"
End If
End With
With e.Form.Controls("模糊条件")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " OR "
End If
Filter = Filter & "BBDGY like '*" & .Value & "*'"
End If
End With
With e.Form.Controls("模糊条件")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " OR "
End If
Filter = Filter & "GZZT like '*" & .Value & "*'"
End If
End With
With e.Form.Controls("模糊条件")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " OR "
End If
Filter = Filter & "BZ like '*" & .Value & "*'"
End If
End With
If Filter > "" Then
Tables("YXKH").Filter = Filter
End If
-------------------------------------------------------------------------
问题:我把其他字段的的条件注释掉,单独只留LCMC(如下),执行查询是正常的,但是像上面那样,全部执行的时候,LCMC这个字段的条件就失效,求解!
Dim Filter As String
With e.Form.Controls("模糊条件")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " OR "
End If
Filter = Filter & "LCMC like '*" & .Value & "*'"
End If
End With
If Filter > "" Then
Tables("YXKH").Filter = Filter
End If