Table of contents
Collapse the table of content
Expand the table of content

ODSOFilter.Comparison Property (Office)

office 365 dev account|Last Updated: 6/12/2017
1 Contributor

Gets or sets an MsoFilterComparison constant that represents how to compare the Column and CompareTo properties. Read/write.


expression. Comparison

expression A variable that represents an ODSOFilter object.


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 Object

Other resources

ODSOFilter Object Members

© 2018 Microsoft