ComponentOne True DataControl 8.0
UserFindData Event

 

UserFindData Event

Occurs in DataMode = 2 - UserEvents, when the control needs to find a row based upon a similar filter.

Syntax

TData_UserFindData (ByVal StartLocation As Variant, ByVal ReadPriorRows As Boolean, ByVal Col As Integer, ByVal Value As Variant, ByVal SeekFlags As Integer, NewLocation As Variant)

Remarks

Arguments: StartLocation is a bookmark that specifies the starting row for the search.

ReadPriorRows indicates the direction in which to search for data. If False, you should provide data in the forward direction starting with the row specified by StartLocation. If True, you should provide data in the backward direction, starting with the row specified by StartLocation.

Col is a field (column) index that specifies the field for the search. It is an index in the Fields collection returned by the Fields property.

Value is the value to be searched for.

SeekFlags is a SeekFlagsEnum value that provides additional information about how the search should be performed. It should be one of the following values:

tdbSeekLT (<)

tdbSeekLE (<=)

tdbSeekEQ (=)

tdbSeekGE (>=)

tdbSeekGT (>)

tdbSeekBeginsWith

tdbSeekContains

tdbSeekNE (<>)

These values may optionally be combined (with "+") with either tdbSeekCaseSensitive or tdbSeekCaseInsensitive. If neither tdbSeekCaseSensitive nor tdbSeekCaseInsensitive is used, it's up to the programmer, the implementer of the UserFindData event, to decide on case sensitivity.

The NewLocation argument is the variable where you should return the bookmark that uniquely identifies the row where the data was found.

In user events mode (DataMode set to 2 - User Events), the UserFindData event is fired when a search must be performed on your data source. You do not need to write a handler for this event unless you want to create your own data source. See User Events Mode for details.

Even in user events mode, implementing the UserFindData event is optional. It  allows you to facilitate search operations for data source. A search operation is performed, for example, when your user calls Recordset.Find. If you don’t implement the UserFindData event, True DataControl will perform an exhaustive search over the data source, record by record. If you know that some of the data source fields allow quicker searching (for example, if they are indexed), you can implement the UserFindData event to improve the search. It is possible (and common) to implement the UserFindData event for certain fields and skip it (set the NewLocation argument to Empty variant) for other fields that are not searchable.

The NewLocation argument is passed to the event procedure as Empty variant You must find the first row meeting the search condition (field value matches the search value with respect to the comparison operation, SeekFlags argument) and return the found row bookmark in the NewLocation argument. If you performed the search and reached the end of your data without finding a row meeting the condition, set the NewLocation argument to Null. Setting NewLocation to Empty variant will make True DataControl perform an exhaustive search.

See Also

TData Control

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback