How to get Dbgrid to display a dropdown list lazarus / 16-Databases ---------------------------------------------------------------------- talorigomat · 2014-10-05 04:01 I have a dataset named assignments which contains an assignment id, employee id and department id and its data is being displayed in a dbgrid.  I have another dataset holding department information (department id, department name). I'm trying to setup the dbgrid so that it displays the department name which it looks up from the department dataset. On the assignments dataset I've opened the 'edit fields' window added a new field as type lookup and completed the required information, ie: Key field - Orgid dataset - department Lookupkeys - Orgid Result Fields - DeptName At design time the dbgrid displays the value.  However when I run the program I get an error stating that "operation cannot be performed on an inactive dataset. All my datasets and transactions are made active in the forms onShow method.  If I remove the lookup field from the dbgrid the program runs without this error message. ---------------------------------------------------------------------- sin_dragan · 2014-10-05 06:38 Hi, can you show code or screenshot, I'm not sure that I understand the problem? You want to show department name in dbgrid, you can join tables in your query that would return dataset with department name. If you want to edit a record then you should use dblookupcombobox component in edit form and set ListSource to Department list and KeyField and DataField to department id. ---------------------------------------------------------------------- talorigomat · 2014-10-07 14:20 I've attached a screenshot of what I'm attempting to do.  This was orignially done using microsoft access and I'm rewriting it using Lazarus (version 1.2.4) and Firebird (version 2.5.2).  The Specialty column has a dropdown list box  from which the user can select an item. I attempted to follow the advice found on the following website: http://www.linkedin.com/groups/ASK-display-combox-as- value-4558772.S.197174056 (see Reshi M. reply which is 8th in the list). All my datasets and transactions are set to active in the form first opens by the FormShow event.  Code: [Select]procedure TfrmGuidance.FormShow(Sender: TObject); begin   qryguidance.Active := True;   qryStatus.Active := True;   qryType.Active :=True;   qryOrg.Active:= True;   qryguidance.Refresh;  // Values in combobox won't display on first open without   qryAssign.Active:= True;   trnAssign.Active:=True;   trnlookups.Active:= True; qryOrg is the dataset for the organisation table and it's transaction property is linked to trnlookups. ---------------------------------------------------------------------- TraumTaenzerDieter · 2014-10-07 15:00 KeyField and LookupKeys have same name: is that correct?? Key field - Orgid : must be the Id in the Detail-Dataset! dataset - department : is that the Lookup-Dataset? Lookupkeys - Orgid : Same name?? are you sure?? Result Fields - DeptName : what will be displayed in the grid instead of the Key-Field, so it must come from the lookup-dataset. The error suggests that you open your Detail-Dataset before you open your Lookup-Dataset: could be verified by breakpoints. ---------------------------------------------------------------------- talorigomat · 2014-10-10 07:27 After restarting my computer the dropdown list in the dbgrid seems to be working fine.  To answer TraumTaenzerDieter question, the KeyField and LookupKeys have similar names. OrgId is the name of the key field in the department table.  The assignment table also has a field named OrgId also, which of course will hold the id of the depart that was selected. Many thanks for helping.