Microsoft KB Archive/156733

= PRB: Error Message with BROWSE and SET FILTER Commands in Form =

Article ID: 156733

Article Last Modified on 10/15/2003

-

APPLIES TO


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

-



This article was previously published under Q156733



SYMPTOMS
When using a SET FILTER or BROWSE FOR commands to filter and display records in a form, the following error may appear:

"Object is not contained in a form."

The Debug window normally points to the BROWSE command as the line causing the error condition.



WORKAROUND
Use the following syntax to browse the desired records in the example created in the Steps to Reproduce Behavior section of this article: x='"' + ALLTRIM(ThisForm.Text2.Value) + '"' SET FILTER TO &x $ Test.cfield1 BROWSE

- or-

x='"' + ALLTRIM(ThisForm.Text2.Value) + '"' BROWSE FOR &x $ Test.cfield1 When you define the variable x in this example, a pair of single quotation mark characters (') enclose a double quotation mark character (").



STATUS
This behavior is by design.



MORE INFORMATION
Sometimes the SET FILTER and the BROWSE FOR commands encounter difficulty resolving object references. Therefore, you need to create a memory variable to hold the object reference as a string. Then use macro substitution to place the memory variable in the command.

Steps to Reproduce Behavior
  Create a table called test and add four records with the following commands: CREATE TABLE test (cfield1 c(10)) INSERT INTO test (cfield1) VALUES ("a") INSERT INTO test (cfield1) VALUES ("a") INSERT INTO test (cfield1) VALUES ("b") INSERT INTO test (cfield1) VALUES ("b")  Create a form called test. Add Test.dbf to the Data Environment of the form. Drag cfield1 to the form creating a Text field, and close the Data Environment window. Add another Text box, Text2, to the form. This control should have no ControlSource.  In the LostFocus event of Text2, add the following code: SET FILTER TO ALLTRIM(Thisform.Text2.Value) $ Test.cfield1 BROWSE You could also use the following line of code: BROWSE FOR ALLTRIM(ThisForm.Text2.Value) $ Test.cfield1 </li> Run the form, enter the letter b in the Text2 field, and press the TAB key to trigger the LostFocus event. Note that the error "Object is not contained in a form" appears.</li></ol>

Additional query words: kbdsd VFoxWin

Keywords: KB156733

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.