We are DOA2006 and Delphi 2006.
We have a need to perform a TOracleQuery after the user switches from one record in the dbgrid to another. The user is using the down arrow or clicking on the navigator bar to switch records. We get a access violation in the AfterScroll event to fill some tEdit fields. Basically there is a 6 digit code that we look up the description for in a table and display it outside the dbgrid along with other dbedit fields.
We put a ShowMessage in the AfterScroll event and it fires many times before the screen even displays and after the dbgrid and dbedit fields display. What event can we put our code in where the event only gets called once after the user moves to a different row and we know we can access the data (field values)? The note in AfterFetchRecord syas the record is not available yet and it says to use the NewValue of the fields instead. This is not an update application. If this is not the event we can use can you suggest which event we can do this?
procedure fillSicMrDesc;
var
bindcode : String;
lenBindcode : Integer;
Begin
lenBindCode := -1;
CMPA0017frm.oqGetSicMrDesc.Close;
bindcode := CMPA0017frm.odsDol_Employers.FieldByName('SIC_MR').Text;
lenBindcode := length(bindcode);
if lenBindcode = 0 then
begin
CMPA0017frm.edtSicMrDesc.Text := '';
exit;
end;
CMPA0017frm.oqGetSicMrDesc.SetVariable('BINDCODE', bindcode);
try
CMPA0017frm.oqGetSicMrDesc.Execute;
except
on E:EDatabaseError do
begin
ShowMessage(E.Message);
ShowMessage('oqGetSicMrDesc Query produced no results');
Exit;
end
end;
CMPA0017frm.edtSicMrDesc.Text := CMPA0017frm.oqGetSicMrDesc.GetVariable('BINDDESC');
end;
Thanks in advance.
Bruce
We have a need to perform a TOracleQuery after the user switches from one record in the dbgrid to another. The user is using the down arrow or clicking on the navigator bar to switch records. We get a access violation in the AfterScroll event to fill some tEdit fields. Basically there is a 6 digit code that we look up the description for in a table and display it outside the dbgrid along with other dbedit fields.
We put a ShowMessage in the AfterScroll event and it fires many times before the screen even displays and after the dbgrid and dbedit fields display. What event can we put our code in where the event only gets called once after the user moves to a different row and we know we can access the data (field values)? The note in AfterFetchRecord syas the record is not available yet and it says to use the NewValue of the fields instead. This is not an update application. If this is not the event we can use can you suggest which event we can do this?
procedure fillSicMrDesc;
var
bindcode : String;
lenBindcode : Integer;
Begin
lenBindCode := -1;
CMPA0017frm.oqGetSicMrDesc.Close;
bindcode := CMPA0017frm.odsDol_Employers.FieldByName('SIC_MR').Text;
lenBindcode := length(bindcode);
if lenBindcode = 0 then
begin
CMPA0017frm.edtSicMrDesc.Text := '';
exit;
end;
CMPA0017frm.oqGetSicMrDesc.SetVariable('BINDCODE', bindcode);
try
CMPA0017frm.oqGetSicMrDesc.Execute;
except
on E:EDatabaseError do
begin
ShowMessage(E.Message);
ShowMessage('oqGetSicMrDesc Query produced no results');
Exit;
end
end;
CMPA0017frm.edtSicMrDesc.Text := CMPA0017frm.oqGetSicMrDesc.GetVariable('BINDDESC');
end;
Thanks in advance.
Bruce