The Find Builder

The Find Object can be used by all units in a project that need a find function, and is intended to mitigate, if not eliminate, the creation of new and unique code to satisfy a particular unit's find requirements.

The Find object consists of two distinct but paired elements: a serially reusable services object that provides common processing services to its paired UI; and a modal Find UI that receives specific information from the invoking module that will direct the find characteristics.

The services object has only one instance in a project or application, typically created and released by the application's main form, or more commonly in the project's Application Object. The Find UI can have multiple instances, one (and only one) for each module instance.

The purpose of the Find UI is to allow the user to build a WHERE clause that will be used to open an associated data query. This is done by selecting the column names from a FieldNames list box, followed by choosing a condition that must be met, and finally either entering a value, or selecting a lookup in a combo box, to complete a SQL statement line. The order by which this is done is unary, with each step enabled after a proper precursor step is completed. If the data query has an initial WHERE statement then it will always be at the start of the final WHERE clause and cannot be removed.

The default query display consists of the WHERE clause statements as they are being built, called the "user's syntax". If the Query panel is double clicked then the display will be changed to detail the entire query in the actual SQL syntax as it will be sent to the database; this will remain in effect until either the query panel is double clicked again, or any other control button is pressed, in either case the user's syntax will again be displayed.

When the Find button is pressed, the assembled query will consist of the original SelectFrom, the new WHERE, and any ORDERBY statements (including HAVING and GROUPBY), which together will be available as a form property. Any ORDERBY section that was in the SQL text when the Find UI was first opened will be overridden by an OrderBy section subsequently assembled.

The OrderBy control operates as a toggle. When activated, all other controls are disabled, the order by edit line has a white field, and the FieldNames list box acts as a multiple line selector. Only fields that have a data kind of fkData can be added to the OrderBy. The order of columns added to the OrderBy is that of their selection in the FieldNames list box. Selected columns in the FieldNames list box remain highlighted as they are added to the order by edit line. If a selected FieldName is again selected, it is removed from the order by. If the CLEAR button is pressed then the assembled order by is cleared. Finally, the order by assembly is terminated if either the ORDERBY button is pressed again, or if the Query panel is double clicked to display the actual SQL syntax.


An example of the Find Builder when it is first opened in an application.