PRB: Cannot Turn Off Filter when Using Cursor Filter Property

Last reviewed: November 7, 1996
Article ID: Q158844
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, versions 3.0, 5.0

SYMPTOMS

When using the filter property of a cursor, there is no apparent way to turn off the filter. Also, setting the filter to an empty string ("") does not remove the filter.

RESOLUTION

Set the filter to ".T." with the following command:

   ThisForm.DataEnvironment.<cursor>.Filter = ".T."

Or use the SET FILTER TO command with no arguments.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a new form.

  2. Select DataEnvironment from the View menu. Locate the Customer table in the <drive>:\Vfp\Samples\Mainsamp\Data directory. Select customer then click OK in the Open file dialog box, then click Close in the Add Table or View dialog box. This should add Customer to the DataEnvironment.

  3. Drag the cust_id field and the company field to the form.

  4. Add two command buttons to the form. In the click event of the first command button place the following code:

          ThisForm.DataEnvironment.cursor1.Filter = "cust_id = 'ANATR'"
          ThisForm.Refresh
    

    In the click event of the second button place either one of the following two code snippets:

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

          -or
    

          STORE ThisForm.DataEnvironment.cursor1.Alias TO x
          SELECT &x
          SET FILTER TO
    
          ThisForm.Refresh   && Note: record position is not lost with
                             && this code.
    
    
Now, save the form and run it. Click the button Command1 to apply the filter, then click the button Command2 to remove the filter.

REFERENCES

Visual FoxPro Help; search on "Filter property" and "SET FILTER TO command"


KBCategory: kbtool kbprb
KBSubcategory: FxtoolFormdes
Additional reference words: 3.00 5.00 vfoxwin kbdse



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: November 7, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.