Board index » delphi » How to Filter a date field when it is null

How to Filter a date field when it is null

I'm trying to filter out all records that have a date that is blank.  But I
get a error when I set the Filtered = True.

I've tried:    Date = ''          and a few other things.

Thanks
Ed

 

Re:How to Filter a date field when it is null


You must try to filter the record directly in your query (if any) something
like 'Select * from tablename where datefield is null', or implement an
OnFilterRecord event like this:

procedure TForm1.ADODataSet1FilterRecord(DataSet: TDataSet;
  var Accept: Boolean);
begin
  accept:=not dataset.fieldbyname('yourfielddatenamehere').IsNull;
end;

Regards

Eduardo

Ed Brazell <Sele...@home.com> escribi en el mensaje de noticias
3ab657e7$1_1@dnews...

Quote
> I'm trying to filter out all records that have a date that is blank.  But
I
> get a error when I set the Filtered = True.

> I've tried:    Date = ''          and a few other things.

> Thanks
> Ed

Re:How to Filter a date field when it is null


Have you try setting the Filterstring to: 'DateField is null'? I believe
it's working except your fieldname conflicts with internal reserved words.

-JC

Quote
"Ed Brazell" <Sele...@home.com> wrote in message news:3ab657e7$1_1@dnews...
> I'm trying to filter out all records that have a date that is blank.  But
I
> get a error when I set the Filtered = True.

> I've tried:    Date = ''          and a few other things.

> Thanks
> Ed

Other Threads