Skip to main content
Version: Next

QUERY BY EXAMPLE

QUERY BY EXAMPLE ( {aTable}{;}{*} )

ParameterTypeDescription
aTableTableTable for which to return a selection of records, or Default table, if omitted
*OperatorIf passed, the scrolling bar will not be displayed

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.

See also

ORDER BY
QUERY

Properties

Command number292
Thread safe
Modifies variablesOK
Changes current record
Changes current selection
Forbidden on the server