Hi,
I have a DBLookupComboBox and some DBEdit's with the same datasource.
When I change the value of an DBEdit, and then change the value of the Combobox, the data will be posted although the query has dsBrowse state.
I want the user to hit a button to save the changes, and the changes should be rejected if he scrolls the combobox without pressing the save-button before.
What's the best way to do this?
Thank you,
ben
Avoid saving data after browse
On changing the DBLookupComboBox value the DataSet goes in edit state. Changes are saved to the database not right away, but when the Post method is called. This method can be called implicitly, for example on moving to the next record in the dataset.
If you want to control changes completely, then set the DBLookupComboBox.DataSource value to nil. In that case for saving data to the database you can use the following code:
If you want to control changes completely, then set the DBLookupComboBox.DataSource value to nil. In that case for saving data to the database you can use the following code:
Code: Select all
MyQuery.Edit;
MyQuery.FieldByName('FiledName').AsString := DBLookupComboBox.Text;
MyQuery.Post;