HOWTO: Applying, Removing a Filter from Form's DataEnvironment

Last reviewed: March 7, 1997
Article ID: Q164870

The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, versions 3.0, 3.0b, 5.0, 5.0a

SUMMARY

The following article demonstrates how to filter records in the DataEnvironment of a form and how to remove the filter.

MORE INFORMATION

  1. Create a new form and add the Customer.dbf table from the directory <drive>:\VFP\samples\mainsamp\data to the DataEnvironment (from the view menu, select Data Environment.

  2. From the DataEnvironment menu, select Add and then select the customer table.

  3. Drag the customer_id field, the company_name field, and the country field to the form and add three command buttons to the form.

  4. In the click event of the first command button, place the following code:

          ThisForm.DataEnvironment.cursor1.filter = "country = 'Germany'"
          ThisForm.Refresh
    

  5. In the click event of the second button place the following code:

          ThisForm.DataEnvironment.cursor1.filter = ".T."
          ThisForm.Refresh  && Note: Record position is lost with this code.
    

    - or -

          STORE ThisForm.DataEnvironment.cursor1.alias to xVar
          SELECT &xVar
          SET FILTER to
          ThisForm.Refresh  && Note: record position is not lost.
    

  6. In the click event of the third button place the following code:

          SKIP
          IF EOF()
    
             GO BOTTOM
          ENDIF
          Thisform.Refresh
    
    

  7. Save the form and run it. Click the button Command1 to apply the filter, and then click the button Command2 to remove the filter.

REFERENCES

See the Visual Foxpro Help for reference to the Filter property and the SET FILTER TO command.


Keywords : FxotherGeneral FxprgSet kbother kbprg vfoxwin
Version : 3.0 3.0b 5.0 5.0a
Platform : WINDOWS
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.

Last reviewed: March 7, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.