Share via


CompareTo Property [Publisher 2003 VBA Language Reference]

Returns or sets a String that represents the text to compare in the query filter criterion. Read/write.

expression.CompareTo

expression Required. An expression that returns one of the objects in the Applies To list.

Example

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". This example assumes that a mail merge data source is attached to the active publication.

Sub SetQueryCriterion()
    Dim intItem As Integer
    With ActiveDocument.MailMerge.DataSource.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

Applies to | MailMergeFilterCriterion Object