I have these tables in my MySQL database:
I want to display the employee table and job.jobName in DBGrid and allow user to edit it (using DBNavigator maybe).
So I created an ADOQuery with SELECT ... JOIN query, a DataSource and linked a DBGrid DataSource to it.
Everything works, but instead of jobId field I want Job field which displays JobNames, allows to choose it via combobox and sets id in the employee.JobId. Something like this:
I thought that I can achieve it using LookupKeyFields/LookupResultFields properties for JobId field in ADOQuery but in fact it doesn't work for me.
I added an ADOTable which just loads everything from the job table and set JobId field (in ADOQuery) properties: FieldKind = fkLookup, KeyFields = JobId, LookupDataSet = tblJob, LookupKeyFields = IdJob, LookupResultFields = JobName.
But now Job column is just empty and without comboboxes.
Also I found PickList property in DBGrid columns, but it is TStrings, so it allows only displayed string, not separate displayed strings and values. And it did nothing even when I tried to fill it for string field (LastName).
Right click on your qryEmployes dataset, choose new field
ans assign needed values.