Microsoft KB Archive/104339: Difference between revisions

From BetaArchive Wiki
(importing KB archive)
 
m (Text replacement - """ to """)
 
Line 44: Line 44:
== SYMPTOMS ==
== SYMPTOMS ==


If you create a table with an SQL action statement such as SELECT INTO, the new table is not immediately reflected in the TableDefs collection of the database object or property. This may result in the error "Name not found in this collection" (error 3265).
If you create a table with an SQL action statement such as SELECT INTO, the new table is not immediately reflected in the TableDefs collection of the database object or property. This may result in the error "Name not found in this collection" (error 3265).


</div>
</div>
Line 72: Line 72:
=== Steps to Reproduce Problem ===
=== Steps to Reproduce Problem ===


The following program demonstrates this problem. It results in the error &quot;Name not found in this collection&quot; on the Tabledefs.Delete statement.
The following program demonstrates this problem. It results in the error "Name not found in this collection" on the Tabledefs.Delete statement.
<pre class="codesample">  Dim db As Database
<pre class="codesample">  Dim db As Database
   Set db = OpenDatabase(&quot;BIBLIO.MDB&quot;)
   Set db = OpenDatabase("BIBLIO.MDB")
   Print &quot;TableDefs.Count before:&quot;; db.TableDefs.Count
   Print "TableDefs.Count before:"; db.TableDefs.Count
   ' Create new table using SQL action statement:
   ' Create new table using SQL action statement:
   db.Execute &quot;select distinctrow * into NewTable from Authors&quot;
   db.Execute "select distinctrow * into NewTable from Authors"
   ' Remove apostrophe from the following statement to work around problem:
   ' Remove apostrophe from the following statement to work around problem:
   ' db.TableDefs.Refresh
   ' db.TableDefs.Refresh
   Print &quot;TableDefs.Count after: &quot;; db.TableDefs.Count
   Print "TableDefs.Count after: "; db.TableDefs.Count
   ' Now attempt to delete the new table just created:
   ' Now attempt to delete the new table just created:
   db.TableDefs.Delete &quot;NewTable&quot;
   db.TableDefs.Delete "NewTable"
   db.Close
   db.Close
                 </pre>
                 </pre>

Latest revision as of 09:31, 20 July 2020

Article ID: 104339

Article Last Modified on 1/8/2003



APPLIES TO

  • Microsoft Visual Basic 3.0 Professional Edition



This article was previously published under Q104339

SYMPTOMS

If you create a table with an SQL action statement such as SELECT INTO, the new table is not immediately reflected in the TableDefs collection of the database object or property. This may result in the error "Name not found in this collection" (error 3265).

WORKAROUND

Perform TableDefs.Refresh immediately after creating the new table. The Refresh method should be but is not documented for the TableDefs collection in the Visual Basic manuals or Help menu.

  • Create the table using database.Tabldefs.Append instead of using an SQL statement.


STATUS

This behavior is by design.

MORE INFORMATION

A table created with an SQL statement is correctly reflected in the Tabledefs collection after the database is closed then reopened.

Steps to Reproduce Problem

The following program demonstrates this problem. It results in the error "Name not found in this collection" on the Tabledefs.Delete statement.

   Dim db As Database
   Set db = OpenDatabase("BIBLIO.MDB")
   Print "TableDefs.Count before:"; db.TableDefs.Count
   ' Create new table using SQL action statement:
   db.Execute "select distinctrow * into NewTable from Authors"
   ' Remove apostrophe from the following statement to work around problem:
   ' db.TableDefs.Refresh
   Print "TableDefs.Count after: "; db.TableDefs.Count
   ' Now attempt to delete the new table just created:
   db.TableDefs.Delete "NewTable"
   db.Close
                


Additional query words: 3.00 docerr

Keywords: kbprb KB104339