dbc_BeforeAddTable Event

Occurs before an existing free table is added to the active database.

You can use the dbc_BeforeAddTable event to execute code before the table is added to a database. This is useful for programming needs such as controlling whether or under what conditions a table is added to the database or to log the addition of the table. There are two versions of the syntax.

Note

This event does not occur when you create a table in the database.

PROCEDURE dbc_BeforeAddTable(cTableName, cLongTableName) 

PROCEDURE dbc_BeforeAddTable
LPARAMETERS [cTableName, cLongTableName]

Parameters

  • cTableName,
    Specifies the name of the table being added.
  • cLongTableName
    Specifies the long name to be given to the table.

Remarks

To prevent the table from being added to the database, return a value of False (.F.) from this procedure.

Example

PROCEDURE dbc_BeforeAddTable ;
         (cTableName, ;
          cLongTableName)
? '     cTableName     = ' + TRANSFORM(cTableName)     + ' - ' ;
                       + TYPE('cTableName ')
? '     cLongTableName = ' + TRANSFORM(cLongTableName) + ' - ' ;
                       + TYPE('cLongTableName ')
userID      = SUBSTR(SYS(0),AT('#',SYS(0))+2)
IF UPPER(userID) = 'MYALIAS'   && only one user can add tables.
   RETURN .T.
ENDIF
   RETURN .F.
ENDIF
ENDPROC

See Also

Tasks

How to: Enable or Disable DBC Events

Reference

dbc_AfterAddTable Event
dbc_BeforeRemoveTable Event
dbc_AfterRemoveTable Event

Other Resources

Events (Visual FoxPro)
Language Reference (Visual FoxPro)