Page 1 of 1

Limit LookupCombo Elements

Posted: 14.07.2006, 10:22
by jascha
Hallo,
I have a DBGrid with 2 Lookup fields in it. I now want to limit the selectable entrys in the second one depending on the value in the first one.

For better understanding parts of my db:

Master Table:
CREATE TABLE seminare
(
seminar_id serial NOT NULL,
kurs_id int2,
kurs_teile_id int4,
)

Lookup Tables:
CREATE TABLE kurs
(
kurs_id serial NOT NULL,
name varchar(255),
)


CREATE TABLE kurs_teile
(
kurs_teile_id serial NOT NULL,
kurs_id int4,
name varchar(255),
)

in english
kurs=seminar
kurs_teile=seminar_parts

I made seminare to the mastersource of kurs_teile an connected kurs_id. This works perfekt, I only can get the kurs_teile for the selected kurs. But there are problems in displaying the list. Often the kurs_teile lookup field is empty. If I remove the mastersource from kurs_teile it works but then I have to whole list which I dont want.

So
1. Can I somehow fix the displaying of the list?
or
2. Is there an other method to limit the entrys in a Combo box?

Thank You
Jascha

DB: PostgreSQL 8.0
ZeosLib from svn
Delphi 7

Posted: 28.09.2009, 16:54
by bangfauzan
I have the same problem.
MASTER table: (notran, custno, kontak, .....)
KONTAK table (id, nama, ....)
DsMaster.DataSet := MASTER;
KONTAK.MasterSource := dsMaster;
KONTAK.MasterFields:='custno';
KONTAK.LinkedFields:='id';

MASTER contains lookupfield calls luKontak
luKontak.LookupDataset:=KONTAK;
luKontak.KeyFields:='kontak';
luKontak.LookupKeyFields:='id';
luKontak.LookupResultFIeld :='nama';

if I set KONTAK.MasterSource to be Nil, everything work OK, but unwanted list also showed.
but if I set KONTAK.MasterSource to DsMaster (referencing each other), lookupfield will be empty every I call CANCEL method to the MASTER table.
lookupfield works OK before CANCEL method is called;

any idea????

many thanks.