Using TDBEdit content on select query before TSQLQuery.open lazarus / 16-Databases ---------------------------------------------------------------------- lmk · 2015-04-08 02:45 I'm using a TDBEdit with a DataSource + TSQLQuery. What i want is to edit this field (before running SQLQuery.open) and then use it's value to build my select SQL. After the query is executed, the field should behave normally, displaying the current SQLQuery record and so on. I still haven't found a 'clean way' to do it (Very likely that i'm missing something obvious here). I've already tried to leave the TDBEdit with no datasource, to link it with the other components after the execution of the query, but then it seems to be disabled, can't type anything there. Also tried to open the SQLQuery with a query that yields no results, just so I can type on the TDBEdit to run the select again afterwards. This kinda works but the first character that I type on the edit is lost because apparently it causes a insert on the SQLQuery dataset, and after that i can type. If i insert a record after opening the dataset i can avoid the loss of the first character typed, but this is far from a clean solution and would be hard for me to manage (i think). Is there a good way to achieve this behavior? What am i missing? ---------------------------------------------------------------------- mangakissa · 2015-04-08 06:53 No, there isn't. TDBedit requires a datasource for setting the edit open for editing. In your case you can using a TEdit on the same spot as your TDBEdit. Before your Query opens, TEdit will be visieble and enabled. ---------------------------------------------------------------------- Mando · 2015-04-08 08:41 Hi mangakisa: I have some applications that work how you want. This is my algorithm: 1. TDBEdit linked to a Query with actually data. (txField) 2. Insert a record. (qr.insert) 3. in OnExit of TBDEdit, or in a Button click, we get the value in a string variable. (value=txField.text). 4. if "value" <> '' then Cancel changes (qr.cancel)   4.1 Construct the SQL sentence with  the value got in step 3. (aSQL:='SELECT * FROM Table WHERE Field1='+quotedStr(value))   4.2 Close the query control. (qr.close)   4.3  Assign the SQL to query control (qr.SQL.text:=aSQL)   4.4. Open then query control. (qr.open)   4.5. Voila!! you get the table filtered. My method is most complicated: I have many controls TDBEdit, I check th type of fields when  constuct the SQL sentence, I handle wild chars, and other things. But in essence, this is the metod. I use it with a full form with many of the fields from the table. If you only have a field,  consider using a TEdit not linked to the dataset. I hope this can help you. regards. P.d. Excuse my english. ---------------------------------------------------------------------- lmk · 2015-04-09 02:39 Just tried mangakissa's suggestion and it works fine. Going with this for now. Thanks for your help guys