before all .. I USe MyDac 4.40.0.25 with MySQL 5.0.45 with DELPHI 7
so I think you know all the demo that come with delphi7 {{masapp}}
I have a problem in the same way :
I have 2 tables Master and Detail and i use the TMyQuery component.
In the detail table after posting [Detail OnAfterPost ] I've put some code to get Sum of one Field in this detail and post it in the master table
Description of Tables
Master Tables
CREATE TABLE `pers` (
`CodeM` char(5) NOT NULL,
`Nom` varchar(50) default NULL,
`Prenom` varchar(50) default NULL,
`Total` double default NULL,
PRIMARY KEY (`CodeM`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
DEtail
CREATE TABLE `detail` (
`CodeD` int(11) NOT NULL auto_increment,
`CodeM` char(5) default NULL,
`Qte` float default NULL,
`PU` decimal(15,2) default NULL,
PRIMARY KEY (`CodeD`),
KEY `FK_detail` (`CodeM`),
CONSTRAINT `FK_detail` FOREIGN KEY (`CodeM`) REFERENCES `pers` (`CodeM`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
the Code that I use is
Code: Select all
procedure TForm1.DetailAfterPost(DataSet: TDataSet);
var
b:TBookmark;
p : Currency;
begin
p:= 0;
b:= Detail.GetBookmark ;
Detail.DisableControls;
Detail.First;
while not Detail.Eof do
begin
p := p+DetailCalculated.Value;
Detail.Next;
end; // while
Detail.EnableControls;
if bnil then
begin
Detail.GotoBookmark(b);
Detail.FreeBookmark(b);
end;
if Master.StatedsEdit then
Master.Edit;
MasterTotal.Value:= p;
end;
why the cursor don't return to the prevus or next record
thanks