Why doesn′t work

this piece of Code:

  if frDataModule.tbFactor.Active then frDataModule.tbFactor.Close;
  frDataModule.tbFactor.MasterSource:=frDataModule.dsEncFac;
  frDataModule.tbFactor.MasterFields:='fcCodigo';
  frDataModule.tbFactor.Open;
  if frDataModule.tbSubFactor.Active then frDataModule.tbSubFactor.Close;
  frDataModule.tbSubFactor.MasterSource:=frDataModule.dsEncFac;
  frDataModule.tbSubFactor.MasterFields:='sfCodigo';
  frDataModule.tbSubFactor.Open;
  frDataModule.qryEncFac.Open;

What I want is to establish a master-detail relationship between a TQuery
and two TTable, I also tried moving this tables to my form and it didnt
work

I