Microsoft KB Archive/149000

= PRB: REQUERY Function Reopens a View's Table Exclusively =

Article ID: 149000

Article Last Modified on 9/30/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition

-



This article was previously published under Q149000



SYMPTOMS
If you requery a view to refresh it with new data, the table with which the view is associated will be opened exclusively -- if it has been closed after the view was opened. This occurs even if SET EXCLUSIVE is off. Requerying a view opens the associated table if that table is not already open.



WORKAROUND
To make sure that the table that is associated with the view stays open in shared mode, do not close the table after the view has been opened. For example, a form may close the table; and then the view gets requeryed.

Another possible resolution to repopulating a control with new data is to set the rowsource (or recordsource) to an empty string, perform the requery and then set the rowsource or recordsource to the original value, as follows: ThisForm.Combo1.Rowsource="" Requery ThisForm.Combo1.Rowsource=" ".



STATUS
This problem has been fixed in Visual FoxPro 5.0.



MORE INFORMATION
If a view is opened and its associated table is not already open, the table will be opened exclusively or shared depending on current Visual FoxPro settings. For example, if EXCLUSIVE is set to Off, the table will be opened shared. If the table is closed while the view is still open, requerying the view with the REQUERY function will open the table exclusively no matter what the EXCLUSIVE setting.

Steps to Reproduce Behavior
 Make sure EXCLUSIVE is set On by typing the following in the Command window. Creating a view requires that EXCLUSIVE be set on.

SET EXCLUSIVE ON

 Open the \Vfp\Samples\Data\Testdata.dbc database. On the File menu, click New. Then click View, and click the New File button. Select the Customer table from the Add Table or View dialog box. Click the Fields tab, and then click the Add All button. On the File menu, click Save, and save the view with the name View_Customer. Close the view. Now the view is created.  On the Window menu, click View Window. Observe the tables as they are opened and closed as you type the following commands in the Command window: CLOSE TABLES SET EXCLUSIVE OFF USE view_customer SELECT customer WAIT WINDOW IIF(ISEXCLUSIVE("customer"),"Exclusive", "Shared") USE SELECT view_customer =REQUERY SELECT customer WAIT WINDOW IIF(ISEXCLUSIVE("customer"),"Exclusive", "Shared") </li></ol>

After you reopen the view, the View_Customer view is open exclusively because that is the only way a view can be opened. The Customer table will be automatically opened when the View_Customer view is opened, and because EXCLUSIVE is set Off, the WAIT WINDOW command shows it as being opened shared. After you close the Customer table and call the REQUERY function on the view, the Customer table is opened exclusively even though EXCLUSIVE is set OFF.

Keywords: kbprb KB149000

-

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

© Microsoft Corporation. All rights reserved.