SetFilter

Method
Assigns a filter to a specified field.

Category
Filters

 

Syntax
Sub SetFilter(ByVal hTable As Long, ByVal FieldNo As Long, ByVal FilterStr As String)

hTable
The handle to the table.

FieldNo
The number of the field for which a filter will be set.

FilterStr
The filter expression for the field, consisting of alphanumeric characters and one or more of the following operators: < > ? & | =

 

Example

'Case "SetFilterGetFilter"

'Sets the filter (from Parameter1 at "Currency"-field from "Customer"-table

'and gets the filter afterwards

  CF1.OpenTable hTable, 18

  logWr "No. of records before applying filter: " & Str$(CF1.RecCount(hTable))

  tmpStr = frmCfrontTest.Text1(cf.FilterCurrency).Text

  CF1.SetFilter hTable, 22, tmpStr

  logWr "No. of records after applying filter: " & Str$(CF1.RecCount(hTable))

  tmpVar = CF1.GetFilter(hTable, 22)

  If VarType(tmpVar) = vbString And tmpStr = tmpVar Then

  logWr "GetFilter OK"

  Else

  logWr "GetFilter failed"

  End

  End If

  CF1.CloseTable hTable

 

Comments
SetFilter assigns a filter to FieldNo. Any filter already assigned to FieldNo for this table handle is removed before the new filter is attached. If FilterStr is an empty string, no filter will be assigned to FieldNo, and any filter currently assigned will be removed.

For more information about filter syntax and relational operators, see the Application Designer’s Guide.



© 2009 Microsoft Corporation. All rights reserved.