Subject [IBO] Re: Field not found
Author Gerard J.M.Houtenbos
At 09:37 PM 12/04/2005 +0200, you wrote:


>At 11:04 AM 12/04/2005 +0200, you wrote:
>
> > I use a TwwDBGrid with programmatically filled columns:
> >
> >with MyGrid.Selected do
> >begin
> > Clear;
> > Add('DEBITOR' + #9 + '14' + #9 + 'Deb' + #9 + ');
> > Add('ARTICLE' + #9 + '16' + #9 + 'Article' + #9 + 'T');
> >end;
> >
> >I use a TwwSearchDialog with the same selected property.
> >If I use the SearchDialog and search for a not existing value then an
> >error shows up with "Column unknow DEBITOR".
>
>Correctly, since your DEBITOR field is not a database column.
>
>gh: Ok, but an existing value is no problem. How come ???

>.I don't know how those controls work, but a reasonable guess is that >hey
>search the buffers first and then query the table if the search match is
>not found. The "field not found" error then occurs when the search query
>is requested.

>Helen

Helen, I figured out that the control work with a Locate on tha
dataset. That's why I made the following solution. I catch the action
where the search take place and substitute it by the following code:


procedure TForm.GridSearchDialogPerformCustomSearch(Sender: TObject;
LookupTable: TDataSet; SearchField, SearchValue: String;
PerformLookup: Boolean; var Found: Boolean);
var
lFound: Boolean;
begin
with TIBOQuery(LookupTable) do
begin
try
lFound := Locate(SearchField, VarArrayOf([SearchValue])
, [loCaseInsensitive, loPartialKey]);
except
lFound := False;
end;
end;
Found := lFound;
end;

In my opinion the problem thus is caused by the fact that the Locate
implementation of TIBOQuery can't work with aliased fields. Am I
correct? The people of Woll2Woll tested it with a normal TQuery and
that's working fine.

tia,

Gerard


_________________________

Gerard J.M. Houtenbos
DoubleWood Software