The information in this article applies to:
- Microsoft Visual FoxPro for Windows, versions 3.0, 5.0
- Microsoft Visual FoxPro for Macintosh, version 3.0b
SUMMARY
This article shows by example how to display only those records that meet a
given criteria in a grid on a form.
MORE INFORMATION
To display only those records that meet a given criteria, use one of the
following three methods:
- If you want to restrict the output to records where status='Y', select
the table being displayed in the grid, and then use the SET FILTER TO
<expression> command, as in this example:
SELECT <TableName>
SET FILTER TO status = 'Y'
-or-
- Create a query that selects the required records, and save it. Set the
grid's RecordSourceType property to 3 - Query and the RecordSource
property to the .QPR file for your query.
-or-
- Use a parameterized view. To create a parameterized view, choose View
Parameters from the Query menu in the View Designer, or use the CREATE
SQL VIEW command with a "?" symbol and a parameter name, as in this
example:
CREATE SQL VIEW customer_data;
AS SELECT * FROM customer WHERE customer.country = ?cCountry
This example includes all records where the Country field in the
Customer table match the value in the cCountry memory variable. If
cCountry did not exist at the time the form was created, a dialog box
would appear asking for the value of cCountry. To use a parameterized
query as the source of data for the grid, set the RecordSource property
to 1 - Alias and the RecordSource property to the name of the view.
|