We have a requirement to edit columns in the native Delphi 7 dbGrid component. In this case we are trying to validate days worked. The user's specfic requirement is if days worked is greater than 7, force the user back to that cell to re-enter the correct value. We would like to validate date fields as well that are in cells in the dbGrid. Here is the code that gets a EVariantInvalidArgErr exception on the line of code that is bold. If we do not set the value in the dataset, the validate event keeps firing in a loop because the value is still greater than 7 and does not give the user a chance to set the value less than 8. How can we get the dbGrid cell to behave the way we need it to?
procedure TFRIA0030dm.odsBatchSroiIndemnitiesPAY_ADJ_DAYS_PAIDValidate(
Sender: TField);
begin
if Sender.AsString > '7' then
begin
ShowMessage('Must be between 0 and 7!');
FRIA0030frm.dbgIndemnities.SetFocus;
FRIA0030dm.odsBatchSroiIndemnities.FieldByName('PAY_ADJ_DAYS_PAID').Value := '';
FRIA0030frm.dbgIndemnities.SelectedField := odsBatchSroiIndemnities.FieldByName('PAY_ADJ_DAYS_PAID');
Exit;
end;
end;
Thanks.
Bruce
procedure TFRIA0030dm.odsBatchSroiIndemnitiesPAY_ADJ_DAYS_PAIDValidate(
Sender: TField);
begin
if Sender.AsString > '7' then
begin
ShowMessage('Must be between 0 and 7!');
FRIA0030frm.dbgIndemnities.SetFocus;
FRIA0030dm.odsBatchSroiIndemnities.FieldByName('PAY_ADJ_DAYS_PAID').Value := '';
FRIA0030frm.dbgIndemnities.SelectedField := odsBatchSroiIndemnities.FieldByName('PAY_ADJ_DAYS_PAID');
Exit;
end;
end;
Thanks.
Bruce