Method
Sets a range filter for a field.
Category
Filters
Syntax
Sub SetRange(ByVal hTable As Long, ByVal FieldNo As Long, ByVal
MinValue As Variant, ByVal MaxValue As Variant)
hTable
The handle to the table.
FieldNo
The number of the field for which the filter is to be set.
MinValue
The starting value. If set to an empty variant, the filter is
removed, regardless of the contents of MaxValue.
MaxValue
The ending value. If an empty variant, the range is set to
MinValue..MinValue.
Example
'Case "SetRangeGetRange"
'Lists all the customers between Parameter1 and Paramter2
CF1.OpenTable hTable, 18
tmpVar = frmCfrontTest.Text1(cf.SetRangeLow).Text
tmpVar2 = frmCfrontTest.Text1(cf.SetRangeUpp).Text
logWr "No. of records before setting range: " & Str$(CF1.RecCount(hTable))
CF1.SetRange hTable, 1, tmpVar, tmpVar2
logWr "No. of records after setting range: " & Str$(CF1.RecCount(hTable))
tmpVar = CF1.GetRange(hTable, 1)
If VarType(tmpVar) = vbVariant + vbArray Then
logWr "Rangefilter retrieved: " & tmpVar(0) & ", " & tmpVar(1)
Else
logWr "GetRange failed"
End If
CF1.CloseTable hTable
Comments
SetRange provides a quick way to set a simple filter on a field.
Any filter that is already assigned to the field is removed.
If MaxValue is set to an empty variant, the range is set to MinValue alone.
Both MinValue and MaxValue must be of the same type as FieldNo.