int result = Application->MessageBox("Czy chcesz usunac przedmiot?", "Uwaga",
MB_YESNO | MB_ICONWARNING);
if(result == IDYES)
{
TblPrzedmioty->SetKey();
TblPrzedmioty->FieldByName("Nazwa_Przedmiotu")->AsString=dbgrdPrzedmioty->Fields[2]->AsString;
TblPrzedmioty->GotoNearest();
TblOceny->First();
while(!TblOceny->Eof)
{
while(TblOcenyNrIndeksu->Text==TblStudenciNr_indeksu->Text)
{
while(TblOcenyIDPrzedmiotu->Text==TblPrzedmiotyIdPrzedmiotu->Text)
TblOceny->Delete();
TblOceny->Next();
}
TblOceny->Next();
}
TblRokAkademicki->First();
while(!TblRokAkademicki->Eof)
{
while(TblRokAkademickiNrIndeksu->Text==TblStudenciNr_indeksu->Text)
{
while(TblRokAkademickiIdPrzedmiotu->Text==TblPrzedmiotyIdPrzedmiotu->Text)
TblRokAkademicki->Delete();
TblRokAkademicki->Next();
}
TblRokAkademicki->Next();
}
QPrzedmioty->Close();
QPrzedmioty->ParamByName("p1")->AsString = TblStudenciNr_indeksu->Text;
QPrzedmioty->Open();
}
}

Chodzi o to, ze jest tabela z przedmiotem, gdzie nazwe pobieram z komponentu dbgrid, jak sie ustawi nazwa to automatycznie tez bedzie znany ID przedmiotu. No i zrobilem petle, zeby mi wyszukiwal w dwoch tabelach rekordu zgodnego z ID przedmiotu i numerem indeksu studenta. Wydaje mi sie, ze powinno dzialac, no ale niestety sie sypie:( Albo podczas usuwania sie zawiesi albo usunie za duzo rzeczy dla danego studenta:( Uzywam borland 6 enterprise a dostep do danych przy pomocy ODBC.