CompareTo 属性
优质
小牛编辑
125浏览
2023-12-01
返回或设置一个 String 类型,表示查询筛选条件中的比较文本。可读写。
expression.CompareTo
expression 必需。该表达式返回“应用于”列表中的对象之一。
示例
本示例更改已有筛选,从邮件合并中删除所有 Region 域不等于“WA”的记录。
Sub SetQueryCriterion()
Dim appOffice As Office.OfficeDataSourceObject
Dim intItem As Integer
Set appOffice = Application.OfficeDataSourceObject
appOffice.Open bstrConnect:="DRIVER=SQL Server;SERVER=ServerName;" & _
"UID=user;PWD=;DATABASE=Northwind", bstrTable:="Employees"
With appOffice.Filters
For intItem = 1 To .Count
With .Item(intItem)
If .Column = "Region" Then
.Comparison = msoFilterComparisonNotEqual
.CompareTo = "WA"
If .Conjunction = "Or" Then .Conjunction = "And"
End If
End With
Next intItem
End With
End Sub