Board index » delphi » Field not found when trying to set filter ???

Field not found when trying to set filter ???

Hi all

I'm getting a strange error: "field not found" when trying to set filter
on a client dataset.  Underlying dataset is a query, passed via DCOM to
the client app.  There are a few datetime fields in the dataset, say
DateA, DateB, DateC, DateD.  DateA and DateC are defined as not null on
the server (interbase).  
Ok, client app has 8 datetime pickers: MinDateA, MaxDateA, MinDateB etc.
Filter expression is constructed as
  if MinDateA.Checked then fstr:= fstr + ' AND (DateA <= ''' +
  DateToStr(Trunc(MinDateA.Date)) + ''') ' ...
with brackets and ANDs where appropriate -- the idea is to filter on
of dates.  It works fine except when MaxDateC is the only picker checked
or, rather, when "(DateC <= 'xx/xx/xx') "  comes first in the filter
Then I get EDbError "field DateC not found".

Now, "(DateC >= 'xx/xx/xx') AND (DateC <= 'yy/yy/yy') " works.  So does
other filter expression) AND (DateC <= 'xx/xx/xx') ".  "(DateC <=
AND (any other filter expression)" does not.

After staring at various filter strings for an hour in de{*word*81}, I
decided to
add (DateC >= '01/01/80') to the filter to get around the problem --
it didn't work!  However, adding
  MinDateC.Checked:= True;
  MinDateC.Date:= 01/01/80 (as a number, of course)
worked.  In both cases filter string is "(DateC >= '01/01/80')
AND (DateC <= 'xx/xx/xx') ".  One works, the other doesn't.  I must be
missing something very obvious here.
Anyone can tell me what it is that I'm missing?  Any suggestions are



Re:Field not found when trying to set filter ???

Rudy Versele wrote:

> Hi Dimitri,

> I use DateTimeToString instead of DateToStr, and I haven't any
> problems with the queries.
> last 14 days:
> { with ADate: string; and DateA as a fieldname }
>     DateTimeToString(ADate,'m"/"d"/"yyyy',Trunc(Now-14));
>     ...SQL.Add('where DateA >= "'+ ADate +'" order by DateA;');

> Maybe that's what you need,

Thanks, I'll keep that in mind.  I had problems with DateTime parameters
in queries, too, so I now trunc() all dates -- unless I need time info
as well
-- and that seems to work.

In this case the problem's different: setting filter on a client dataset
"(DateField >= 'xx/xx/xx') AND (DateFiels <= 'yy/yy/yy') "  works
"(DateField <= 'yy/yy/yy') " gives EDbError "field DateField not found".
Very strange.


Re:Field not found when trying to set filter ???

Right click the tQuery component, and make sure the field
appears in the Fields Editor, or add it if needed.
Rick Carter

Other Threads