Board index » delphi » DBGrid and lookupfields

DBGrid and lookupfields

I have a Table1 which has a Alphanumeric key (1 field). I have a
Table2 which has a numeric key (1 field).

I have a Table3 which has two fields which are lookups from Table 1
and Table2.

To insert new records editing of the fields is done in the DBGrid

Here's the problem: I pick a value for the first lookupfield from
Table1 (the alphanumeric one). Now when the dropdown of the second
field is executed I get a Convert Error (StrToInt).

It's trying to use (and convert) the value of the keyfield of the
first lookup as keyvalue for the second table (which is integer).

Anyone else has experienced this (or is able to reproduce it) ? What
is a decent workaround for the problem ?

Any help appreciated.

PS. I made a PrintScreen of the callstack window if anyone needs it to
make the problem more clear.


Re:DBGrid and lookupfields

On Tue, 22 Feb 2000 10:27:20 +0100, Mark Smits <>


>PS. I made a PrintScreen of the callstack window if anyone needs it to
>make the problem more clear.

With the help of the call stack I traced to real problem to
DBGrids.pas (Delphi 5, around line 810):

FDataList.ListSource := ...
FDataList.KeyValue := ...

Since KeyValue is part of the problem, I changed the execution order
of these two to:

FDataList.KeyValue := ...
FDataList.ListSource := ...

As far as I can tell everything seems to work 100%.

Any thoughts of what might go wrong with this adjustment ?

Thanks again,

Other Threads