Table of contents

ODSOFilter.CompareTo 属性 (办公室)ODSOFilter.CompareTo Property (Office)

office 365 dev account|上次更新日期: 2018/3/13
2 参与人员

获取或设置一个字符串,表示查询筛选条件中的比较文本。读/写。Gets or sets a String that represents the text to compare in the query filter criterion. Read/write.


表达式CompareToexpression. CompareTo

表达式_一个表示ODSOFilter对象的变量。_expression A variable that represents an ODSOFilter object.


下面的示例将现有筛选器更改为从邮件合并中删除“Region”字段不等于“WA”的所有记录。The following example changes an existing filter to remove from the mail merge all records that do not have a Region field equal to "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

另请参阅See also


ODSOFilter 对象ODSOFilter Object

其他资源Other resources

ODSOFilter 对象成员ODSOFilter Object Members

© 2018 Microsoft