DOCUMENT:Q130707 11-AUG-1999 [foxpro] TITLE :HOWTO: Use Criteria to Limit Records Displayed in a Grid PRODUCT :Microsoft FoxPro PROD/VER: OPER/SYS: KEYWORDS:kbDesigner kbvfp300 kbvfp500 kbvfp600 ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual FoxPro for Windows, versions 3.0, 5.0, 6.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 described below. Method One ---------- 1. If you want to restrict the output to records where status='Y', select the table being displayed in the grid. 2. Next, use the SET FILTER TO command, as in this example: SELECT SET FILTER TO status = 'Y' Method Two ---------- 1. Create a query that selects the required records, and save the query. 2. Set the grid's RecordSourceType property to 3 - Query and the RecordSource property to the .QPR file for your query. Method Three ------------ 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. Additional query words: browse key ====================================================================== Keywords : kbDesigner kbvfp300 kbvfp500 kbvfp600 Technology : kbHWMAC kbOSMAC kbVFPsearch kbAudDeveloper kbVFP300bMac kbVFP300 kbVFP500 kbVFP600 Issue type : kbhowto ============================================================================= THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Copyright Microsoft Corporation 1999.