Query by Form

Ordering Records

With Query by Form you order records based on the contents of one to five different fields. For example, using Query by Form you can sort customer records by State, then City, then Lastname, and finally Firstname.

You specify record-ordering criteria in Order Criteria view, where number boxes appear next to the form fields.

To order records in your form:

  1. Select Query > Query by Form... or click .

  2. Click  on the toolbar.

  3. Click the box at the upper left corner of each field to assign its sorting sequence. For example, click on the State field box to assign the number 1 and designate the State field as the first (most important) criteria for ordering records. Clicking on subsequent order number boxes for other fields assigns the numbers 2, 3, 4, and 5, indicating the hierarchy for ordering records.

  4. Optionally, click the arrows next to the numbers to specify ascending (up arrow) or descending (down arrow) order. Click Run Query any time to perform the query.

Order Number Boxes

  1. Click the Clear Criteria button at any time to reset ordering.

  2. Quick Run Query to display the first sorted record.

  3. Click , , or to view the other sorted records.

Selecting Records

Query by Form makes record selection easy. To find records that match specific criteria, you type the criteria directly in the fields of the form. For example, if you are viewing a table of customers and you want to view only customers from Massachusetts, you would type MA (the value for which you are looking) in the State field and run the query.

To select records using your form:

  1. Select Query > Query by Form... or click .

  2. Click  on the toolbar.

  3. Optionally, if you understand filter syntax, enter filter criteria directly into the form fields.

    1. You can specify multiple conditions; for example, you can type "MA" in the State field and "Springfield" in the City field. This query selects only customers who live in Springfield, Massachusetts.

    2. You can also use query operators, such as a comma, when specifying conditions. The comma is used as a logical OR. For example, by entering "NY,MA" in the State field, Alpha Five selects customers who live in New York or Massachusetts.

  4. Optionally, for assistance is entering filters, click to display the QBF Helper. Query by Form has a special syntax and using the QBF Helper helps you learn it. You can use the QBF Helper on any of the form fields.

    1. Click in a form field and then click one of the expression buttons in the QBF Helper.

    2. The QBF Helper prompts you for a value to finish the expression.

    3. Alpha Five fills the resulting expression in the form field.

  5. Optionally, use any Alpha Five function as Part of your search criteria. For example, the SOUNDEX() function allows for spelling variations. In a form with a LASTNAME field, you could enter SOUNDEX(LASTNAME)=SOUNDEX("Johnson") to search for last names of "Johnson" and spelling variations of "Johnson".

Querying with Multiple Forms

  1. When creating elaborate OR queries, you can use multiple forms for the query. To move to additional query condition pages, click , , or to view the other forms to use in the query. Alternatively, press the Page Up or Page Down keys on your keyboard. When the query runs, Alpha Five will return records satisfying conditions on all the forms.

  2. Optionally, click the Include Records   button on the toolbar. The query will return only records that match the search criteria.

  3. Optionally, click the Exclude Records   button on the toolbar. The query will return only records that do not match the search criteria.

  4. Optionally, click the Show Expressions button  on the toolbar to see the Xbasic expressions that you are using in your query.

  5. Click Run to apply the filter and to display the first record that matches the query criteria.

  6. Click , , or to view the other records that satisfy the query.

  7. Click Clear to clear all filter criteria.

  8. Click on the toolbar to show all records.

Query by Form Syntax

Operator

Description

Examples

Explanation

<

less than

<7

<Fred

<4/16/2002

less than seven

occurs before "Fred" (alphabetically)

occurs before the date 4/16/2002

>

greater than

>7

>Fred

>4/16/2002

greater than seven

occurs after "Fred"

occurs after 4/16/2002

<>

not equal to

<>7

<>Fred

<>4/16/2002

not equal to seven

not "Fred"

does not occur on 4/16/2002

>=

greater than or equal to

>=7

>=Fred

>=4/16/2002

is greater than or equal to seven

is "Fred" or comes after "Fred"

occurs on or after 4/16/2002

<=

less than or equal to

<=7

<=Fred

<=4/16/2002

is less than or equal to seven

is "Fred" or comes after "Fred"

occurs on or before 4/16/2002

*

wildcard character

fr*

*ed

value starts with "fr"

value ends with "ed"

, (comma)

logical OR

car, truck

value equals "car" or "truck"

..

between

1..7

A..M

4/16/2001..4/16/2002

is between one and seven

is between A and M

occurs between 4/16/2001 and 4/16/2002

is blank

is blank

is blank

the field is empty

is not blank

is not blank

is not blank

the field is not empty

$

contains

$ software

the field contains the word "software" anywhere within the field

Saving and Opening Queries

Alpha Five lets you save queries you create in Query-by-Form for future use. To save a query:

  1. Define your search criteria and click the Save button  on the toolbar.

  2. Alpha Five prompts you to name the query and saves it.

  3. Saved queries appear on the Operations tab in the Control Panel.

To open a saved query:

  1. Click the Open button  on the toolbar.

  2. Alpha Five prompts you for the location of the query and opens it.

To create a new query:

  1. Click the New button  on the toolbar.

  2. Alpha Five opens a new, blank query form.

To remove saved queries place the following Xbasic statement under the OnPush event of a button:

dim tbl as P

tbl = table.current()

tbl.query_detach_all()

See Also

Query by Form, The CustQueryReport Form, Query Operations, Query Genie, Query Builder