Método OfficeDataSourceObject.ApplyFilter (Office)OfficeDataSourceObject.ApplyFilter method (Office)

Aplica um filtro a uma fonte de dados de mala direta para filtrar registros especificados que atendam a critérios especificados.Applies a filter to a mail merge data source to filter specified records meeting specified criteria.

SintaxeSyntax

expression.expression. ApplyFilter

expressão Uma variável que representa um objeto OfficeDataSourceObject .expression A variable that represents an OfficeDataSourceObject object.

ExemploExample

Este exemplo adiciona um novo filtro que remove todos os registros com um campo Região em branco e aplica o filtro à publicação ativa.This example adds a new filter that removes all records with a blank Region field and then applies the filter to the active publication.

Sub OfficeFilters() 
 Dim appOffice As OfficeDataSourceObject 
 Dim appFilters As ODSOFilters 
 
 Set appOffice = Application.OfficeDataSourceObject 
 
 appOffice.Open bstrConnect:="DRIVER=SQL Server;SERVER=ServerName;" & _ 
 "UID=user;PWD=;DATABASE=Northwind", bstrTable:="Employees" 
 
 Set appFilters = appOffice.Filters 
 
 MsgBox appOffice.RowCount 
 
 appFilters.Add Column:="Region", Comparison:=msoFilterComparisonEqual, _ 
 Conjunction:=msoFilterConjunctionAnd, bstrCompareTo:="WA" 
 appOffice.ApplyFilter 
 
 MsgBox appOffice.RowCount 
 
End Sub

Ver tambémSee also

Objeto OfficeDataSourceObjectOfficeDataSourceObject Object

Membros do objeto OfficeDataSourceObjectOfficeDataSourceObject Object Members