This documentation is archived and is not being maintained.

MailMergeDataSource.EditRecord Method

Office 2007
Changes one of the data fields in one of the records in the master data source (the combined mail-merge recipient list).

Version Information
 Version Added:  Publisher 2007


expression.EditRecord(lRec, varField, Value)

expression   A variable that represents a MailMergeDataSource object.


NameRequired/OptionalData TypeDescription
lRecRequiredLongThe ID of the record you want to edit.
varFieldRequiredVariantThe data field (column) that contains the value you want to change.
ValueRequiredVariantThe value to be changed.


You can use the EditRecord method to correct data source information that is in error, such as an outdated recipient address.

The EditRecord method does not make any changes to the individual data sources that together make up the master data source.


The following Microsoft Visual Basic for Applications (VBA) macro shows how to use the EditRecord method to change the value of a single column in a particular record in the master data source (the combined mail-merge recipient list).

Before running this macro, replace recordID with the index number of the record in the data source that you want to edit; replace fieldname with the name of the field (column) in the record that you want to edit; and replace value with the new value you want to set for the field.

Visual Basic for Applications
Public Sub EditRecord_Example()
    Dim pubMailMergeDataSource As Publisher.MailMergeDataSource
    Set pubMailMergeDataSource = ThisDocument.MailMerge.DataSource
    pubMailMergeDataSource.EditRecord recordID, "fieldname", "value"

End Sub