QUERY BY EXAMPLE
QUERY BY EXAMPLE ( {aTable}{;}{*} )
Parameter | Type | Description | |
---|---|---|---|
aTable | Table | → | Table for which to return a selection of records, or Default table, if omitted |
* | Operator | → | If passed, the scrolling bar will not be displayed |
This command is not thread-safe, it cannot be used in preemptive code.
Description
QUERY BY EXAMPLE performs the same action as the Query by Example menu command in the Design environment. It displays the current input form as a query window. QUERY BY EXAMPLE queries aTable for the data that the user enters into the query window. The form must contain the fields that you want the user to be able to query. The query is optimized; indexed fields are automatically used to optimize the query.
See the 4D Design Reference manual for information about using the Query by Example menu command in the Design environment.
Example
The method in this example displays the MyQuery form to the user. If the user accepts the form and performs the query (that is, if the OK system variable is set to 1), the records that meet the query criteria are displayed:
FORM SET INPUT([People];"MyQuery") // Switch to query form
QUERY BY EXAMPLE([People]) // Display form and perform query
If(OK=1) // If the user performed the query
DISPLAY SELECTION([People]) // Display the records
End if
System variables and sets
If the user clicks the Accept button or presses the Enter key, the OK system variable is set to 1 and the query is performed. If the user clicks the Cancel button or presses the “cancel” key combination, the OK system variable is set to 0 and the query is canceled.