Главная страница | назад





Article #17166: Specify a DefaultExpression for a TField object

 Question and Answer Database

FAQ2166D.txt   Specify a DefaultExpression for a TField object
Category   :Database/VCL
Platform    :All
Product    :Delphi 3.x  

Question:
How do I specify a DefaultExpression for a TField object? 

Answer:
If you set up a field attribute set and associate that set with 
a field in your table that will work. If you set the value in 
the object inspector it will let you enter in a string but it 
will not reflect the value at runtime. If you try to set the 
TField.DefaultExpression property at runtime like this: 

MyField.DefaultExpression := 'MyValue';

It will compile but you will not get a default value at runtime 
when you create a new record in the table by, say, clicking on 
the + on the DBNavigator. To get the default value to take at 
runtime the code assignment needs to be: 

MyField.DefaultExpression := '''MyValue''';

In the Object Inspector. You just need to put 'MyValue'. Use 
single quotes in the Object Inspector. 

7/16/98 4:31:28 PM
 

Last Modified: 01-SEP-99