Microsoft KB Archive/135265

= How to Use a Combo Box to Filter the Contents of a Grid =

Article ID: 135265

Article Last Modified on 10/15/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b for Macintosh

-



This article was previously published under Q135265



SUMMARY
It is possible to use a combo box in Visual FoxPro to filter the contents of a grid by using the value property of the combo box.



MORE INFORMATION
To filter out certain records within a table, use the SET FILTER command along with the value property of the combo box.

Step-by-Step Example
 Create a form by using the CREATE FORM command. Open the Testdata.dbc database in the VFP\Samples\Data directory. Add the Customer table to the data environment. Drag the Customer table from the data environment onto the form to create a grid.  Add a combo box to the form from the controls toolbar, and in the Name property, type: cboTest  In the RowSource property of the combo box, type some data that you know is in the table, separating each of the values with commas. For example, type:

Germany,France,Spain

 For the RowSourceType property, select Value.  In the Click event of the combo box, type this code: SELECT Customer SET FILTER TO Country = Thisform.cboTest.Value Thisform.Refresh  Save and Run the form. When you selecting one of the items in the combo box, the grid reflects only those records that pertain to that item.</li></ol>

Additional query words: 3.00 VFoxMac VFoxWin

Keywords: KB135265

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.