Microsoft KB Archive/156030

= PRB: SET RELATION TO Has No Effect in Grid from Child =

Article ID: 156030

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 Q156030



SYMPTOMS
If you create a form containing a grid whose record source is a child table in a relation that is broken with the SET RELATION TO command, the grid behaves as if the relation were still set and continues to show a subset of records from the child table.



CAUSE
For performance reasons, the relation information is cached and is not reread until the grid is forced to reevaluate its record source.



WORKAROUND
Set the grid's record source to the grid itself to clear the cached information and to force the grid to reevaluate its record source, as in the following example: Thisform.Grid1.RecordSource = Thisform.Grid1.RecordSource Additionally, setting the grid's record source to itself does not cause the grid to lose nondefault properties as it did in Visual FoxPro 3.0b.



STATUS
This behavior is by design.



Steps to Reproduce Behavior
 Create a new form called Temp.  Add the following two tables to the data environment: VFP\samples\data\customer.dbf VFP\samples\data\orders.dbf  Add a text box to the form.  Set the text box's ControlSource property to the following: Customer.cust_id  Add a grid to the form.</li> Set the grid's RecordSource property to Orders.</li> Add a command button to form.</li>  Place the following code in the Click method of the command button: SELECT Customer   && Select Parent table SET RELATION TO   && Turn off relation </li> Run the form.</li> Click the command button.</li></ol>

The grid continues to show only child records related to the first record in the parent table.

To incorporate the workaround into this example, add the following code as the third line of the Click method of the command button on the form created above: Thisform.Grid1.RecordSource = Thisform.Grid1.RecordSource Run the form, and click the button. The grid updates to show all child records.

Additional query words: kbdse VFoxWin

Keywords: KB156030

-

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

© Microsoft Corporation. All rights reserved.