Board index » delphi » HELP ! - Using TQuery with TDBLookupList

HELP ! - Using TQuery with TDBLookupList

I need to have a list box displaying a filtered selection of data
from a table. The filter is on a boolean field in a paradox 5
database.

When I try to attach a TDataset based on a TQuery to a TDBLookupList
box I get an error saying that a TDBLookupList box must be connected
to a dataset based on a table.

 

Re:HELP ! - Using TQuery with TDBLookupList


In article <00009413+00002...@msn.com>, Robert Wood <Rob_G_W...@msn.com>
writes

Quote
>I need to have a list box displaying a filtered selection of data
>from a table. The filter is on a boolean field in a paradox 5
>database.

>When I try to attach a TDataset based on a TQuery to a TDBLookupList
>box I get an error saying that a TDBLookupList box must be connected
>to a dataset based on a table.

If you want to filter the records you will have to iterate the table to
find those that match your filtering criterion. Why not use a standard
TListBox and a TTable and link this code to your Form's Show event or to
a TTable event if you want to update the list after the user makes a
change;

...
{Prevent updates to other TDB... controls}
Table1.DisableControls;
{Erase old listbox contents}
ListBox1.Clear;
with Table1 do begin
  try
    First;
    while not EOF do
      {Check record meets criterion}
      if Fields[1].AsBoolean = True then
        {Add whatever to the listbox}
        ListBox1.Items.Add(Fields[2].AsString);
  finally
    EnableControls;
  end;
end;

In my experience with Paradox 5.0 tables this is very fast.
--
Barney Tyrwhitt-Drake

Re:HELP ! - Using TQuery with TDBLookupList


In article <00009413+00002...@msn.com>, Rob_G_W...@msn.com says...

Quote
> I need to have a list box displaying a filtered selection of data
> from a table. The filter is on a boolean field in a paradox 5
> database.

> When I try to attach a TDataset based on a TQuery to a TDBLookupList
> box I get an error saying that a TDBLookupList box must be connected
> to a dataset based on a table.

That's right, you ,unfortunately, can't combine a TDBLookupList with a
TQuery.
--
Paul Sjoerdsma, software developer / designer
The Global Aquaculture Network

Re:HELP ! - Using TQuery with TDBLookupList


Quote
Paul Sjoerdsma wrote:

> In article <00009413+00002...@msn.com>, Rob_G_W...@msn.com says...
> > I need to have a list box displaying a filtered selection of data
> > from a table. The filter is on a boolean field in a paradox 5
> > database.

> > When I try to attach a TDataset based on a TQuery to a TDBLookupList
> > box I get an error saying that a TDBLookupList box must be connected
> > to a dataset based on a table.

> That's right, you ,unfortunately, can't combine a TDBLookupList with a
> TQuery.
> --
> Paul Sjoerdsma, software developer / designer
> The Global Aquaculture Network

But you can create a temporary table and use TBatchMove with your TQuery
as the source.  Create indexes on the temporary table as required & use
it as the datasource for your TDBLookupList.

It sounds like a lot of work but its not too bad. ;-)

Matthew O'Haire
mat...@ozemail.com.au

Other Threads