FindRecord Method

Microsoft Publisher Visual Basic

expression.FindRecord(FindText, Field)

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

FindText    Required String. The text to look for.

Field    Optional String. The name of the field to be searched.

Example

This example displays a merge publication for the first data record in which the FirstName field contains Joe. If the data record is found, the record number is stored in a variable.

Sub FindDataSourceRecord()
    Dim dsMain As MailMergeDataSource
    Dim intRecord As Integer

    'Makes the data in the data source records instead of the field codes
    ActiveDocument.MailMerge.ViewMailMergeFieldCodes = False

    Set dsMain = ActiveDocument.MailMerge.DataSource

    If dsMain.FindRecord(FindText:="Joe", _
            Field:="FirstName") = True Then
        intRecord = dsMain.ActiveRecord
    End If

End Sub