Reindexing master/detail DBase files in a program

I'm trying to build a routine that I can use to reindex
master/detail DBF files from a program.  The database will
be located on a Novell LAN so I'm trying to set the tables'
Exclusive property to true. The following routine was
adapted from a Borland example. When trying to reindex a
detail table I get a 'Table is Busy' exception when trying
to set the table active after setting exclusive to true. This
happens as a stand alone application, its not running on the
Network yet.  If I initially set the Detail Table Active property
to False before starting the program it will work. Is there something
else required to set the Exclusive property true or what is causing
the table to indicate it's busy?

 I also have found that I have to clear the Detail Table's
"indexFiledNames" and "MasterFields" properties before reindexing
(unlink the Master Detail table?). Does this seem correct and is
that all that needs to be done or did it just happen to work in this case?

procedure MakeTableExclusive (TableX: TwwTable; DBName: string);
{ Try to open Table1 with Exclusive True }

begin
  { First, close Table }
  TableX.Active := False;
  repeat { until successful or Cancel button is pressed }
     try
        TableX.Exclusive := True; { See if it will open }
        TableX.Active := True;  <======Error Occurs===========
        Break; { If no error, exit the loop }
     except
        on EDatabaseError do
           { Ask if it is OK to retry }
           if MessageDlg('Could not open ' + DBName +
             ' exclusively - OK to retry?',mtError,[mbOK, mbCancel], 0) <>
mrOK
               then raise; { If not, reraise to abort }
      { Otherwise resume the repeat loop }

     end;
  until False;
end;

Bob Harman
EMail: RHarman313.aol.com