BeforeOpenTables, AfterCloseTables

These two events (and their associated methods) relate to the Data environment of forms, reports and labels. These events give you the opportunity to take actions before the tables are opened and after the tables close.

Usage

PROCEDURE DataEnvironment.BeforeOpenTables 
PROCEDURE DataEnvironment.AfterCloseTables
As its name suggests, BeforeOpenTables happens before tables are opened, which is very early in the firing sequence. This makes it a good place to do anything you want to happen right away. We've been known to put some environmental settings (such as SET DELETED ON) in there.AfterCloseTables isn't the last event. The Destroy events of the Data environment and the objects it contains happen later.When we started testing this stuff, we got a real shock. BeforeOpenTables does not fire before the OpenTables method. That's because BeforeOpenTables is misnamed. A better (though terribly unwieldy) name would be BeforeAutoOpenTables because this event fires right before tables are opened automatically. If there's custom code in OpenTables, that code executes, then BeforeOpenTables fires, then the tables are automatically opened. (Of course, this behavior means there's not much use for BeforeOpenTables. Almost anything you'd want to put there could just as soon go in the OpenTables method.)

Example

* This might be a report's BeforeOpenTables method
* where the DE contains a view, so you need to set
* things up so the view's query gets the right results
PROCEDURE BeforeOpenTables
 
SET DELETED ON
SET ANSI ON

See Also

AutoCloseTables, AutoOpenTables, CloseTables, OpenTables


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .