Microsoft KB Archive/141912

= PRB: AutoOpenTables/AutoCloseTables Ignored in Program =

Article ID: 141912

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 Q141912



SYMPTOMS
When creating a form visually, you discover that the data environment's AutoOpenTables property is set to True (.T.) by default and the tables and views will automatically be opened when the form is run. If the data environment is instantiated from within a program, the value of AutoOpenTables and AutoCloseTables is ignored.



WORKAROUND
Call the OPENTABLES or CLOSETABLES methods directly.



STATUS
Microsoft is researching this behavior and will post new information here in the Microsoft Knowledge Base as it becomes available.



Steps to Reproduce Behavior
  Create a new program file, and type the following code: ******* Begin Program **********

public oData1 oData1=CREATEOBJECT("MyData") && Instaniate the Data Environment

DEFINE CLASS MyData AS dataenvironment  && DataEnvironment Class Name = "Dataenvironment" AutoOpenTables=.T.  AutoCloseTables=.T.   ADD OBJECT "Cursor1" AS MyCursor     && ADD OBJECT for each ENDDEFINE                           && cursor in Dataenvironment

DEFINE CLASS MyCursor AS cursor     && Cursor Class Alias = "author" Database = "C:\vfp\samples\data\testdata.dbc" CursorSource = "customer" Name = "Cursor1" ENDDEFINE

******* End Program *******  Run the program. Check the View window. You will see that no tables are opened. The Data Environment's AutoOpenTables is ignored. In the Command window type:

oData1.OpenTables

NOTE: If the Testdata.dbc is not in your Path, you need to locate it. Note that the table is opened. Inside the Command window, type:

oData1.CloseTables

</li> The OpenTables/CloseTables must be called directly because AutoOpenTables and AutoCloseTables are ignored.</li></ol>

Additional query words: VFoxWin

Keywords: KB141912

-

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

© Microsoft Corporation. All rights reserved.