Erro no FOR... URGENTE !!!
09/05/2003
0
for i := 0 to DM.TblProdMatPrima.RecordCount -1 do begin if DM.TblProdMatPrimaCod_Produto.Value = StrToInt(DBFinderEdit2.Text) then begin for j := 0 to DM.TblMatPrima.RecordCount -1 do begin if DM.TblMatPrimaCodigo.Value = DM.TblProdMatPrimaCodMatPrima.Value then begin DM.TblMatPrima.Edit; DM.TblMatPrimaQntEst.Value := DM.TblMatPrimaQntEst.Value - (DM.TblProdMatPrimaQnt.Value * RXSpinEdit1.Value); DM.TblMatPrima.Post; end; end; end; end;
É o seguinte pessoal, no segundo FOR ele está entrando 2 vezes no IF, porém quero que só entre uma vez, pois só existe um cadastro no BD, alguém sabe identificar o erro no código?
Desde já agradeço
[]´s
Titanius
Curtir tópico
+ 0
Responder
Posts
09/05/2003
Adilsond
DM.TblProdMatPrima.First; while not DM.TblProdMatPrima.EOF do begin if DM.TblProdMatPrimaCod_Produto.Value = StrToInt(DBFinderEdit2.Text) then begin DM.TblMatPrima.First; while not DM.TblMatPrima.EOF do begin if DM.TblMatPrimaCodigo.Value = DM.TblProdMatPrimaCodMatPrima.Value then begin DM.TblMatPrima.Edit; DM.TblMatPrimaQntEst.Value := DM.TblMatPrimaQntEst.Value - (DM.TblProdMatPrimaQnt.Value * RXSpinEdit1.Value); DM.TblMatPrima.Post; end; DM.TblMatPrima.Next; end; end; DM.TblProdMatPrima.Next; end;
Imagino que suas tabelas estejam ligadas (master/detail)???
Outra maneira, dependendo da estrutura de suas tabelas, seria localizar os registros com locate.
Responder
Clique aqui para fazer login e interagir na Comunidade :)