Query Mode > Using True DataControl to Formulate a Query |
Query mode is allowed only for a TData control in data source mode, DataMode = 0 - DataSource. Identical TData fields are used in query and result mode, but the function of a data field is different:
In result mode, a data field is used to display a field of data in the resulting recordset. In query mode, the value entered by the end-user in a data field represents a query, or search value, it is used to generate a condition imposed on the resulting recordset.
For a TData control in query mode, the QueryFilter property returns the filter condition generated from the data entered by the end-user.
Each non-empty field value generates a condition of the form:
Example Title |
Copy Code
|
---|---|
DataSourceField = value |
where DataSourceField is determined by the field’s DataSourceField property, and the value is the field value entered by the end-user in query mode. This can be further generalized by using comparison operations other than "=." For more information, see Field comparison operation.
If there are multiple non-empty field values in a row, their corresponding conditions are joined with AND. Conditions generated by different rows are joined with OR.
Suppose the user entered two rows of data in query mode:
ProductName |
SupplierID |
Chocolade |
22 |
|
1 |
Generated query will be:
(ProductName = “Chocolade” AND SupplierID = 22) OR SupplierID = 1