Microsoft KB Archive/158844

= PRB: Cannot Turn Off Filter when Using Cursor Filter Property =

Article ID: 158844

Article Last Modified on 11/17/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



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. .Filter = ".T." Or use the SET FILTER TO command with no arguments.



Steps to Reproduce Behavior
 Create a new form. Select DataEnvironment from the View menu. Locate the Customer table in the :\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.

