I am using cxGrid in which I have two date fields (start_date and end_date) which get its results from a query. I am trying to prevent user from entering wrong date span when entering data in the grid. I am trying to prevent user from entering end_date lower than the start_date. I tried :
procedure TForm1.ABSQuery1BeforePost(DataSet: TDataSet);
begin
if (ABSQuery1.FieldByName('end_DATE').AsDateTime < ABSQuery1.FieldByName('start_DATE').AsDateTime) then
showmessage('end date cant be lower than start date ');
ABSQuery1.Cancel;
end;
I get error : dataset is not in insert or edit mode. How can I fix this or is there a better way to do this ?