Creates a temporary table and a handle to it.



Function OpenTemporaryTable(ByRef hTableRef As Long, ByVal TableNo As Long) As Boolean

The handle to the temporary table.

The number of the database table to be used as a template for the temporary table.



'Case "OpenTempTable"

  tmpVar = CF1.OpenTemporaryTable(hTable, 15)

  If VarType(tmpVar) = vbBoolean Then

  logWr "openTemporaryTable OK"


  logWr "OpenTemporaryTable failed. It didn't return a boolean"

  End If

  CF1.CloseTable hTable


OpenTemporaryTable creates a temporary table based on the table description of the "real" table with TableNo. The temporary table can be accessed like any other table by using hTableRef.

You cannot perform transactions on a temporary table because it is not a part of the database. The temporary table does not exist outside the application that creates it. Consequently, it is also "private" for the application that creates it, and other users in a multi-user system cannot access it. Other than this, you can perform the same operations as on a "real" table.

The benefit of using a temporary table is that it is held in memory and this makes performing operations on it very fast. In a client/server environment, this also reduces the load on the network. You can copy records from the corresponding "real" table by using FindRec and NextRec. You cannot use CopyRec because the source and the destination records must be in the same table when you are using this function. When you have performed a series of operations on the records in a temporary table, you can insert these records into the "real" table by using InsertRec or ModifyRec.

© 2009 Microsoft Corporation. All rights reserved.