Refreshing a lookup field value after key value change

1k views Asked by At

I have a two tables :

  • DEPARTMENTS (Index, Name)
  • EMPLOYEES (Index, Name, DEPID, DepName)

DepName is a lookup value which retrieve DEPARTMENTS.Name using DEPID which references DEPARTMENT.Index.

When using a DBGrid displaying the EMPLOYEES table, and after changing DEPID value, the record's DepName is not updated and do not reflect the change until I re-run the query!

Is there anyway to do this and get the lookup value reflect the change live ?

  • Rad Studio XE Tokyo,
  • Firebird 3.0,
  • FireDac components (TFDQuery),
1

There are 1 answers

0
Atreide On

If you can do EMPLOYEES.Post the lookupfield should refresh correctly. In order to keep on Editing the record you can do EMPLOYEES.Edit back again. It is probably not the right way to do it but it did work for me.

You can try CalcField.RefreshLookupList that looks like the accurate way to do it, but it didn't work for me on Delphi XE6 with firedac against Postgres database with cached updates.