Marvin,
Leroy's suggestion will work almost all the time, possibly even all of the time. But it does have a whole in it...someone could theoretically open the file in the short period of time between the function call and your attempt to USE the table.
The best method is to do what Garret has suggested. You can make a function that does this for you. Something like this:
lcOldError = on("error")
llOpenError = .f.
on error llOpenError = .t.
use table1.dbf exclusive in 0
on error &lcOldError
if !llOpenError
else
endif
>What is the best way to check to see if a table can be open exclusively before opening it exclusively and getting an error?
>
>In this case I want to do an ocassional PACK if there are no other users using the database, but of course use summary excl produces an error if other users are using the db.
>
>Thanks!
Steve Gibson