Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Generic in BeforeOpenTables in Data Environment
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Database:
Visual FoxPro
Divers
Thread ID:
00974847
Message ID:
00975125
Vues:
39
Hi Bob.

> I would like to would like to add code in the BeforeOpenTables in the Data Environment of every form that I create.

Since a form class doesn't have a DE, you can't directly do this. What I do is have code in the Load method of the form class that does whatever is necessary, then calls the OpenTables method of the DE. Then, when I create a form from the class, I set the AutoOpenTables property of the DE to .F. That way, the code in Load will execute before any tables are opened and then the call to OpenTables will open the tables. Here's a snippet of code from Load:
with This
  do case
    case type('.DataEnvironment') <> 'O' or ;
      .DataEnvironment.AutoOpenTables
    case type('oApp.Name') = 'C' and pemstatus(oApp, 'SetDataDirectory', 5)
      oApp.SetDataDirectory(.DataEnvironment)
      .DataEnvironment.OpenTables()
    otherwise
      .DataEnvironment.OpenTables()
  endcase
endwith
In this case, the code looks for a global oApp object that has a SetDataDirectory method, and if it exists, calls it prior to calling OpenTables. Of course, your code could do whatever you wish.

Doug
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform