PRB: Error with FILTER or WHERE Including This or Thisform (163185)
The information in this article applies to:
- Microsoft Visual FoxPro for Windows 3.0
- Microsoft Visual FoxPro for Windows 3.0b
- Microsoft Visual FoxPro for Windows 5.0
- Microsoft Visual FoxPro for Windows 6.0
This article was previously published under Q163185 SYMPTOMS
Upon browsing or skipping through a table with a filter condition set, or
through a cursor created with SQL SELECT and a WHERE condition, you may see
one of several errors:
Object is not contained in a FORM.
Object is not contained in a FORMSET.
THIS can only be used within a method.
THISFORM can only be used within a method.
Property <form or formset property holding filter value> is not found.
CAUSE
These errors are caused by the record pointer being moved or the table
being browsed outside of the object where the FILTER or WHERE condition has
been stored in a form or object property. Regardless of where the FILTER
condition is set, or how the record pointer is being moved, the FILTER
condition is reevaluated each time the record pointer is moved. If the
table or cursor is being accessed outside the form or other object where
THISFORM.<property> or THIS.<property> is a valid reference, one of these
errors occurs.
RESOLUTION
To prevent these errors, use macro substitution, or store or reference the
FILTER or WHERE condition in a manner where it is always a valid reference.
You can do this in several ways:
- Set the FILTER condition with macro substitution, for example:
THISFORM.cfilterstring = "cust_id = 'A'"
lcFilterstring = THISFORM.cfilterstring
SET FILTER TO &lcFilterstring
- Store the FILTER condition to a public variable, for example:
PUBLIC gcFilterString
gcFilterString = "cust_id = 'A'"
SET FILTER TO (gcFilterString)
- Store the FILTER condition in a property of an object with a reference
in a public variable. There is an example of this below in MORE
INFORMATION.
- If the error is caused by a WHERE condition in a cursor created with
SELECT - SQL, the NOFILTER keyword may be used in Visual FoxPro 5.0 to
force a temporary table to be used, rather than a filtered subset of the
full table. Here, the WHERE is never reevaluated after the SELECT is
executed, for example:
SELECT * FROM customer WHERE cust_id = "A" ;
INTO CURSOR custcursor NOFILTER
In Visual FoxPro 3.0, this can be forced by adding a calculated field to
the SELECT, such as the following:
SELECT *, SPACE(1) FROM customer WHERE cust_id = "A" ;
INTO CURSOR custcursor
STATUS
This behavior is by design.
REFERENCES
Visual FoxPro 5.0 Help File
Modification Type: | Major | Last Reviewed: | 12/3/2003 |
---|
Keywords: | KB163185 |
---|
|