Logo

Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.

CLOSE TABLES

This command closes open tables. Big surprise. Except that sometimes it closes free tables and sometimes it doesn’t.

Usage

CLOSE TABLES [ ALL ]

When a database is current, CLOSE TABLES closes all the open tables that belong to that database. With no current database, CLOSE TABLES closes all free tables. Add ALL to CLOSE ALL open tables, regardless of the current state of affairs or the origins of the tables. As with CLOSE DATABASES, work area 1 is selected.

From the point of view of this command (and pretty much everywhere else), views are considered tables in the database that owns them, while cursors created with SELECT or CREATE CURSOR are free tables.

In VFP 7, the BeforeCloseTable and AfterCloseTable events fire for tables that belong to a database with Database Events turned on.

Example

OPEN DATA TasTrade
USE Customer IN 0
USE Employee IN 0
USE Orders IN 0

* Now one that's not in the database
USE FoxUser
* Now one from another database
USE TestData!Customer

SET DATABASE TO TasTrade
CLOSE TABLES      && Closes all tables from TasTrade.
CLOSE TABLES ALL  && Closes FoxUser and TestData!Customer.
                  && Both TasTrade and TestData are left open.

See Also

Close Databases, Open Database, Use