How can I use DefaultExpression property for TField with MS Access or SQL Server, it seems to work only with BDE.
Why DefaultExpression property work only with BDE?
1.1k Views Asked by Kachwahed At
2
There are 2 best solutions below
1

Not an exact answer, but it is a workaround. I just call something like the next routine from the AfterInsert event handler of the dataset:
procedure Flds_SetToDefExpr(const AFlds: array of TField);
var
i : Integer;
begin
for i := Low(AFlds) to High(AFlds) do
with AFlds[i] do begin
DataSet.Edit;
if ( DefaultExpression='' ) then
Clear
else if HasOuterQuotes(DefaultExpression) then
Value := RemoveOuterQuotes( DefaultExpression,True,False )
else
Value := StrToInt(DefaultExpression); //raises if not an integer!
end;
end;
Ofcourse you could change this routine to accept a TDataSet, which loops it's fields and does the same to all fields.
I think that DefaultExpression property dosn't work with ADO, but we get workaround using TBetterADODataSet by Vassil Nazarov that use something like:
You can get it for free here: TBetterADODataSet