on dbcombobox1 change update dbcombobox2 lazarus / 16-Databases ---------------------------------------------------------------------- Danyfirex · 2015-07-01 17:47 hi mate. it's me again. is there a way (I mean using dbcombobox properties to do that). I mean this. I have my database.db has many tables some table field is a reference to another table field. example tables: Table1->Person ID|Name|idCountry|idCity|idTown table2->Country ID|country_name table3->City ID|city_name table3->town ID|town_name is there some properties that let me fill the combo with all the field that is refered to. Combocountry1=if i choose some contry combocity get all cities that are refere to that country. combocity2 if i choose a city my combotown3 get all town that are refere to that city. combotown3 here make some similar but with  another things. I know this can be done using my dataset but I asking if exist a fast way with the dbcombobox properties to do that more flexible,fast,practical. Saludos ---------------------------------------------------------------------- taazz · 2015-07-01 17:51 Use DBLookupComboBox instead. ---------------------------------------------------------------------- Danyfirex · 2015-07-01 18:26 mate can you provide me scheme how to se the propierties. I'm trying with DBLookupComboBox but I can't figure me how to do it. Saludos ---------------------------------------------------------------------- taazz · 2015-07-01 18:42 use a query that returns all the records from the country table and a second query that returns all records of the person table and link them to datasources lets name them QryPerson for the person query DSPerson for the person datasource and QryCountry, DSCountry for the country controls respectively. DBLookupCombobox has 2 groups main groups of properties 1) the data to be changed when the combobox is used to select a value and 2) the query that provides the values you can choose from. in the first group are the properties Datasource, Datafield which must be linked to the DSPerson and IDCountry field and in the second group are the properties Listsource linked to dsCountry, listField must be linked to the Country_name field and KeyField that must be linked to the DSCountry.ID field. After that if you use the default property values every time you select a country in the dblookupcombobox it will change the active record's idcountry field value the new one selected. All filling and setting is taken care for you internally. ---------------------------------------------------------------------- Danyfirex · 2015-07-01 20:30 Thank you very much mate that's help me so much. so I have another problem. The code work well. but For example: when I select my contry in my dblookupcomboboxContry my dblookupcomboboxCity get update so. I want to show just the cities from that contry but it show me all my cities. show I work with query on the change event. o could be done with the properties. Saludos ---------------------------------------------------------------------- taazz · 2015-07-01 20:40 It can be done with properties yes. You make sure the city query includes a parameterize where statement. Something along the lines of Code: [Select]QryCity.SelectSql.text := 'Select * from City where IdCountry = :ID' I'm writing id as the name of the id field in the country query, it must much what ever the country query uses for the ID field name exactly, then you set the qryCity.DataSource property to the dsCountry. for more details visit http://wiki.freepascal.org/MasterDetail ---------------------------------------------------------------------- Danyfirex · 2015-07-01 20:43 I solved that part by this way. on the event change make a new query on the City refered to my contry idContry value. Code: [Select]QryCity.Close; QryCity.SQL.Text:='SELECT * FROM City where idCoutry='''+inttostr(LookDBCountry.KeyValue)+''''; QryCity.Open;    So if there is another way let me know it. ¿taazz by properties would be? Sorry if I ask too much. so there is not good reference using that control. Thank you very much Mr. taazz. I'll look the link. Thank you. I'll come back with the result. Saludos