Xbasic

OBJECT.FIND Function

Syntax

Result as C = OBJECT.Find([* findwhat ])

Arguments

Result

*

"ExactMatch" = the method was able to find an exact match for the key you were searching for.
"ClosestMatch" = method found the closest match for the key you were searching for
findwhat

A Character, Numeric, Logical, or Date key value to find. Optional. Default = "" displays the Find by Key dialog.

Integer_Value

The number of a record.

Description

Returns the first record that matches the search criteria.

Discussion

The <OBJECT>.FIND() 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>.FIND() method displays the first record whose key value matches Value. If value is not specified, the built-in Find by Key dialog is displayed. You must examine the contents of the record to determine if it is the one you seek. The search key is determined by the current sort order. You may want to use the <FORM>.INDEX_SET() or the <FORM>.QUICK_SORT() method first to set the sort order of the table.

Example

This script is attached to a button. It sets the primary index to "Last_Name", then finds the record for "McMillan":

parentform.index_set("Last_Name")
parentform.find("mcmillan")

A form has a variable called "What_Name" and a button called "Find". When the user presses the button, the script searches for the name entered into "What_Name".

parentform.index_set("Last_Name")
parentform.find(what_name.value)

A form has two variables: "What_Value" and "Find_by". "Find_by" is a radio button with these choices: "Last name", "Company" and "Phone". The form also has a button called "Find". When the user presses the button, the script searches for the value in "What_Value" using the index selected by the radio button.

SELECT
  CASE find_by.value = "Last_name"
        parentform.index_set("Last_Name")
  CASE find_by.value = "Company"
        parentform.index_set("Company")
  CASE find_by.value = "Phone"
        parentform.index_set("Phone")
end SELECT
parentform.commit()
parentform.find(what_value.value)

Limitations

Desktop applications only.

See Also