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
- Create a new form.
- 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.
- Drag the cust_id field and the company field to the form.
- 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"