DBLookupList + TIBConnection [SOLVED] lazarus / 16-Databases ---------------------------------------------------------------------- timcs · 2014-03-11 19:20 Hi   I am trying to re-write a program I did in Delphi with an Interbase database which has two tables. In the Delphi application I used a DBLookupList to get the entries from one table and this linked then to the other so when an item was clicked on from the DBLookuplist the records from the other table were filtered.   The two tables have a unique field and I have set up the DBLookupList to point to both tables via a TSQLQuery 1 and 2 but when I click on the entries in the DBLookupList, the second table is not being filtered   How do I achieve the same as I did in Delphi Thanks TimCS ---------------------------------------------------------------------- LacaK · 2014-03-13 06:11 Can you attach sample project, which does not work as you expected? ---------------------------------------------------------------------- timcs · 2014-03-13 13:45 Quote from: LacaK on March 13, 2014, 07:11:09 amCan you attach sample project, which does not work as you expected? I will do this as soon as I possible can but I will not be able to include the actual database as it has personal data held in it. Also the links are purely done through the object inspector not via code thanks TimCS ---------------------------------------------------------------------- timcs · 2014-03-13 19:25 Hi   Here is the sample project as requested Thanks TimCS ---------------------------------------------------------------------- mangakissa · 2014-03-14 10:43 I can't find any relation to SQLQuery1  and SQLQuery2 Why do you think the DBLookuplist is filtering? DBLookuplist is using datsource1 on fill the Items. It has nothing to do with filtering. Follow these steps for relations (http://wiki.lazarus.freepascal.org/MasterDetail). QuoteThe two tables have a unique field and I have set up the DBLookupList to point to both tables... There's no code written in your example. I've created a small example with a TLookuplistbox on Countries and Cities. On clicking a item in the listbox, this code will be executed: Code: [Select]procedure TForm1.DBLookupListBox1Click(Sender: TObject); begin   cities.Filter := 'countryid = ' + DBLookupListBox1.Field.AsString;   cities.filtered := true; end; All those things can be done with a master/detail relationship. You don't need a DBLookupList. Why are you using two connections? All SQLQueries can use the same connection. ---------------------------------------------------------------------- timcs · 2014-03-14 13:50 Quote from: mangakissa on March 14, 2014, 11:43:44 amI can't find any relation to SQLQuery1  and SQLQuery2 Why do you think the DBLookuplist is filtering? DBLookuplist is using datsource1 on fill the Items. It has nothing to do with filtering. Follow these steps for relations (http://wiki.lazarus.freepascal.org/MasterDetail). QuoteThe two tables have a unique field and I have set up the DBLookupList to point to both tables... There's no code written in your example. I've created a small example with a TLookuplistbox on Countries and Cities. On clicking a item in the listbox, this code will be executed: Code: [Select]procedure TForm1.DBLookupListBox1Click(Sender: TObject); begin   cities.Filter := 'countryid = ' + DBLookupListBox1.Field.AsString;   cities.filtered := true; end; All those things can be done with a master/detail relationship. You don't need a DBLookupList. Why are you using two connections? All SQLQueries can use the same connection. Thanks mangakissa, the use of the to SQLqueries qas to avoid duplicate records when linking the two tables together plus when I did this in Delphi I did not need to add any code to create the link between the two tables. I had tried at one point to link the two SQLqueries together via the datasource option but this kept giving me an error and crashing Lazarus Thanks for the example code I will look at this in details when I get change Thanks TimCS ---------------------------------------------------------------------- timcs · 2014-03-16 08:03 Hi mangakissa I used the example from the link you provided on master detail to sort this out . Thanks for your input TimCs