Recent

Author Topic: SQLite: How to create lookup fields?  (Read 4158 times)

vice

  • New Member
  • *
  • Posts: 28
SQLite: How to create lookup fields?
« on: December 24, 2008, 04:21:27 pm »
Hi, I have two TSQLite3Dataset components:

DatasetSales with the fields: Code, Item, Amount, Price, Vendor
DatasetItems with the fields: Code, Description

I have a TDBGrid component that shows the data of DatasetSales.

I want to make a lookup field associated to the Item DatasetSales field to show the Code and Description DatasetItems fields.

I do it:

Code: [Select]
procedure TForm1.FormCreate(Sender: TObject);
begin
  with DatasetSales do
    begin
      Open;
      DatasetItems.Open;
      FieldByName('Item').FieldKind := fkLookup;
      FieldByName('Item').LookupDataSet := DatasetItems;
      FieldByName('Item').LookupKeyFields := 'Code; Description';
      FieldByName('Item').LookupResultField := 'Code';
    end;
end;

but nothing happen.

Why?

Thanks and Merry Christmas.
« Last Edit: December 24, 2008, 04:34:16 pm by vice »

tatamata

  • Hero Member
  • *****
  • Posts: 735
    • ZMSQL - SQL enhanced in-memory database
Re: SQLite: How to create lookup fields?
« Reply #1 on: December 25, 2008, 09:38:38 am »
Hi.
You should remove field 'Description' from LookupKeyFields.
In LokupKeyFields put only those fields that are present in both datasets.
It's a link between two datasets.
Regards,

Zlatko

 

TinyPortal © 2005-2018