TDBEdit: .Value or .Text or .Field.Text? lazarus / 16-Databases ---------------------------------------------------------------------- NelsonN · 2011-12-15 14:49 When I assign values to a TDBEdit control in code I usually use this: [TDBEdit].Text := This has always worked, but recently, it was reported to me, that on my Max OS X version of the application it gave this error: "[TDBEdit] may not be NULL" I the read this: QuoteAndersonCarli: 01/04/09 06:25 PM, ID: 23292543 You shoud never assing value directly to Text property of a Dataware control. As you said: Use the underling Field to update the Controls Text. Instead using DBEdit1.Text := 'Some Text' use DBedit1.Field.Value := 'Some Text' You'll update the Contron AND the dataset; I am not using .Value but did opt for this: [TDBEdit].Field.Text := And it seems to be working fine on all platforms now: Windows, Linux, and Mac OS X. My question is, which one, in Lazarus, should be the correct one? .Value or Field.Text? And what is the difference between them? Are there any docs I may read on this that you can point me to? ---------------------------------------------------------------------- ludob · 2011-12-15 15:15 Field.value is a variant while Field.text is a string. Depending on the real field type more or less type conversions are going to be made. Which one is better? Depends. If you know the real field type, better use the native type. It will give you as a bonus compile time warnings/errors if you try to do some unsupported conversion. If you don't know the field type use value (variant). Similar if you don't know the right side of the assignment: use value. If you are lazy and don't want to be bothered with type conversions, use value But beware for the run-time exceptions when trying to convert apples to pears! ---------------------------------------------------------------------- NelsonN · 2011-12-16 11:29 Thanks for the description. I take it then that .Text just changes the component and .Field.Text changes the dataset as well? Or is the error I got on Mac OS X caused by a bug? That is, that .Text and .Field.Text are the same? ---------------------------------------------------------------------- ludob · 2011-12-16 12:06 Quote from: NelsonN on December 16, 2011, 12:29:48 pmI take it then that .Text just changes the component and .Field.Text changes the dataset as well? Or is the error I got on Mac OS X caused by a bug? That is, that .Text and .Field.Text are the same? Writing to DBEdit.Text changes the text in the edit control but does not change the underlying data set. There is no automatic call to DBEdit.DataChange.