PRB: File Collections' Add Method Closes Table (191585)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 6.0

This article was previously published under Q191585

SYMPTOMS

Invoking a file collections' Add method to add a table to a project object causes the table to close.

STATUS

This behavior is by design.

MORE INFORMATION

This behavior also occurs in the user interface. If you add an open table to a project, Visual FoxPro closes the open table.

The following code programmatically demonstrates this behavior. The IIF() statement checks if the table is open and returns a message based on the results.

Steps to Reproduce Behavior

Sample Code

   CLOSE ALL
   CLEAR ALL
   CLEAR
   DELETE FILE test.pj?
   SET SAFETY OFF

   CREATE TABLE testtable (field1 c(10), field2 m)

   LOCAL ;
      loFIle
   USE testtable
   ? IIF(USED("TestTable"), "Test Table is Open!", "Test Table is NOT ;
   Open!")
   MODIFY PROJECT test NOWAIT NOSHOW
   loFIle = APPLICATION.ACTIVEPROJECT.FILES.ADD("TestTable.Dbf")

   IF VARTYPE(loFIle) = "O"
      WAIT WINDOW "File Added!" TIME 1
   ELSE
      WAIT WINDOW "File Not Added!" TIME 1
   ENDIF

   ? IIF(USED("TestTable"), "Test Table is Still Open!", ;
    "Test Table is NOT still Open!")
   APPLICATION.ACTIVEPROJECT.CLOSE()
				

Modification Type:MajorLast Reviewed:12/11/1999
Keywords:kbprb KB191585