Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
FindRecord Method

MailMergeDataSource.FindRecord Method

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

Syntax

expression.FindRecord(FindText, Field)

expression   A variable that represents a MailMergeDataSource object.

Parameters

NameRequired/OptionalData TypeDescription
FindTextRequiredStringThe text to look for.
FieldOptionalStringThe name of the field to be searched.

Return Value
Boolean

Example

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

Visual Basic for Applications
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



Community Additions

ADD
Show:
© 2015 Microsoft