Subject | Re: [IBO] Calculated fields problem.. |
---|---|
Author | Woody (TMW) |
Post date | 2004-10-21T03:48:50Z |
Helen wrote:
query. If I call CalculateFields just after opening the query, the first
name shows up but the rest don't. If I "walk" the records calling
CalculateFields each time, the names are all there. I don't want to do that
everytime I open and close the query, though. There must be something else
happening.
Woody (TMW)
>handlers
> Yes, it is a simple thing. CalculateFields operates on a row, so pick up
> the ARow argument and operate on that. OnCalculateField gets called once
> for each field in the CalcFields array, so AField gives you a reference to
> the calculated field.
> I hope you'll forgive me for pushing the guts of this out into a separate
> function. I get anxiety symptoms when I find myself writing event
> with lots of lines in them. :-)I've gotten to where I try to do the same thing myself. :)
>AField.Fieldname, there is no NAME property for TIB_Column.
> procedure TfrmWorkers.WorkersCalculateField(Sender: TIB_Statement;
> ARow: TIB_Row; AField: TIB_Column);
> begin
> // test not appropriate if Assigned(AField) then
> if AField.Name = 'FULLNAME' then
> with ARow doStill does the same thing. The grid shows empty names just after opening the
> begin
> ByName('FULLNAME') := ConcatNames(
> ByName('FirstName').AsString,
> ByName('MI').AsString,
> ByName('LastName').AsString);
> end;
> end;
>
> function MyDM.ConcatNames (
> String1, String2, String3: String): String;
> begin
> Result := EmptyStr;
> if length(String1) > 0 then
> Result := String1;
> if length (String2) > 0 then
> begin
> if length(Result) > 0 then
> Result := Result + ' ' ;
> Result := Result + String2;
> end;
> if length(String3) > 0 then
> begin
> if length(Result) > 0 then
> Result := Result + ' ' ;
> Result := Result + String3;
> end;
> end;
>
> Also, call CalculateFields whenever you need the calculation done. IBO
> should do it automatically on Open and Refresh (check, though). However,
> because a calculated field isn't a dataset object, you can make it do its
> stuff at other times as well.
query. If I call CalculateFields just after opening the query, the first
name shows up but the rest don't. If I "walk" the records calling
CalculateFields each time, the names are all there. I don't want to do that
everytime I open and close the query, though. There must be something else
happening.
>should
>
> >BTW, I have just downloaded IBObjects within the last 2 weeks so it
> >be the latest version, IB 4.3 Aa, I believe.out
> >
> >Not to disappoint anyone else, but I'm rooting for Helen to figure this
> >since she's so smart with these types of problems. :)Aw come on, Helen, you know you're good. :)
>
> Hmmm.....
>
Woody (TMW)