Share via


dbc_Activate Event

Occurs when a database becomes active. There are two versions of the syntax.

PROCEDURE dbc_Activate(cDatabaseName) 

PROCEDURE dbc_Activate
LPARAMETERS cDatabaseName

Parameters

  • cDatabaseName
    Specifies the name of the database being activated.

Remarks

You can have many Databases open at the same time but only one can be active at a time. A database can become active under several circumstances. To explicitly activate a database, use the SET DATABASE TO command. If several databases (with DBC Events turned on) are open, the dbc_Activate method runs only in the active database.

If you place DBC Events code in a program file, the code applies to any database that specifies that program file as its events file. In this case, DBC events method code can affect several databases at the same time. When you use DBC events in this way, use the cDatabaseName parameter in the event code to specify which database is being activated. This way you can use one block of method code to determine the activated database and then apply code appropriate to that database.

Return False (.F.) from this procedure to prevent the database from being activated.

Visual FoxPro will ignore a return of False (.F.) from this event during design time.

Example

PROCEDURE dbc_Activate ;
         (cDatabaseName)
? '     cDatabaseName  = ' + TRANSFORM(cDatabaseName) + ' - ' ;
                       + TYPE('cDatabaseName ')+' /end/ '
ENDPROC

See Also

Reference

dbc_Deactivate Event

SET DATABASE Command

dbc_CloseData Event

dbc_ModifyData Event

dbc_OpenData Event

Other Resources

Events (Visual FoxPro)

Language Reference (Visual FoxPro)