Xbasic

OBJECT.QUERYRUN Function

Syntax

Record_Count as N = <OBJECT>.Queryrun([c filter_expression [,c order_expression [,c query_name [,c additive [,c level_name [,l displaywarning [,c query_options ]]]]]]])

Arguments

filter_expressionCharacter

An expression that selects records from the table.

order_expressionCharacter

Default = Record order. An expression that orders the records selected.

query_nameCharacter

The name of the query. Use "Temporary Query" to define a query that Alpha Anywhere can discard to make room for new queries.

additiveCharacter

Default = "No". "Yes" = The query is in addition to the form's current query. "No" = The query replaces the form's currency query.

level_nameCharacter

Default = "<Cross Level>". The name of the parent table when the Filter_Expression is based on the child table or the parent and child tables where there is a one-to-many relationship between the parent and child tables.

displaywarningLogical

Default = .F. (FALSE). If no records are found, whether to display a warning.

query_optionsCharacter

Default = "". Refer to <TBL>.QUERY_CREATE()

Returns

Record_CountNumeric

The number of records found by the query.

Description

Returns the number of records selected by the query in the current layout.

The <OBJECT>.QUERYRUN() method applies to:

Browses (for <OBJECT> use either the <BROWSE> pointer or the name of the browse)
Forms (for <OBJECT> use either the <FORM> pointer or the name of the form)

The <OBJECT>.QUERYRUN() method applies a query to the current layout. The method returns the number of records selected by the query.

Example

The current script opens a form and only displays records from Massachusetts:

dim P as P
P = form.load("customer information")
Result = p.QueryRun("bill_state_region = 'ma'")
if (result = 0) then
    ui_msg_box("Error","No records found")
    p.close()
else
    p.activate()
end if

To modify the above script to sort the result by lastname, change the .QUERYRUN() method to:

Result = p.QueryRun("bill_state_region = 'ma'", "lastname")

The following script applies a filter additively. The script is attached to a button on a form:

Old_filter = topparent.filter_get()
Topparent.QueryRun("lastname = 'smith'", "", "", "Yes")
'To "undo" the last query:
Topparent.QueryRun(old_filter)

Limitations

Desktop applications only.

See Also