PRB: Cannot Turn Off Filter when Using Cursor Filter Property (158844)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 3.0
  • Microsoft Visual FoxPro for Windows 5.0
  • Microsoft Visual FoxPro for Windows 6.0

This article was previously published under Q158844

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"

Modification Type:MajorLast Reviewed:11/17/2003
Keywords:KB158844