>>>Try the USE command by itself. This should hopefully close any table that is opened. Let me know if it works.
>>>
>>
>>Ravi,
>>This will close any table open in the current work area. It does not affect other work areas nor does it affect other datasessions.
>
>Let me explain my situation: i have an application with 3 "system control" objects (user information, system configuration and an error handler). I have an option on the main menu called "Database Compression and Cleanup" (PACK/REINDEX). I need to close all forms, objects (those 3 must be kept open) and tables. So I can open the database/tables exclusively and do PACKs and REINDEXes. My point is: CLOSE DATABASES ALL is not closing all tables. When I try to open the tables exclusively, I get an error message saying that the files are in use. Since the tables were opened by objects (that don't have a Data Environment at design time, preventing me from using object.DataEnvironment.CloseTables()) I don't know how to close them.
>
Alonso,
The three system objects open the table in the default datasession or #1. Unless they are session objects, in which case they create their own datasession. In that case, you have to cycle through the open datasessions and close the tables.
local lxx, llerror, lcerror
on error llerror = .T.
llerror = .F.
for lxx = 1 to 50
set datasession to (lxx)
if !llerror then
close databases all
endif
llerror = .F.
endfor
You can jack up the number from 50 or make it smaller depending on the number of active datasessions, you thnik you will have. In VFP 7, you can use the ASessions() function to return the number and ID of any open datasessions.
HTH.
Larry Miller
MCSD
LWMiller3@verizon.netAccumulate learning by study, understand what you learn by questioning. -- Mingjiao