FindRecord Method

Microsoft Word Visual Basic

FindRecord Method

       

Searches the contents of the specified mail merge data source for text in a particular field. Returns True if the search text is found. Boolean.

Note   Corresponds to the Find Record button on the Mail Merge toolbar.

expression.FindRecord(FindText, Field)

expression   Required. An expression that returns a MailMergeDataSource object.

FindText   Required String. The text to be looked for.

Field   Required Variant. The name of the field to be searched.

Example

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

Dim dsMain As MailMergeDataSource
Dim numRecord As Integer

ActiveDocument.MailMerge.ViewMailMergeFieldCodes = False
Set dsMain = ActiveDocument.MailMerge.DataSource
If dsMain.FindRecord(FindText:="Joe", _
        Field:="FirstName") = True Then
    numRecord = dsMain.ActiveRecord
End If