Subject Calculated fields problem..
Author Woody (TMW)
I'm finally evaluating IBO along with embedded FB. So far, everything is
going fine. I do have one slight "glitch" that I can't seem to work out
involving calculated fields. Hopefully I can cover all the needed
information the first time.

Simple table structure:

CREATE TABLE Employee
(
ID INT NOT NULL,
EmpNum VARCHAR(10),
FirstName VARCHAR(20),
LastName VARCHAR(20),
MI CHAR(1),
Street1 VARCHAR(40),
Street2 VARCHAR(40),
City VARCHAR(40),
STATE CHAR(2),
ZIPCODE CHAR(12),
HOMEPHONE CHAR(10),
HireDate DATE,
TerminationDate DATE,
Comment BLOB SUB_TYPE TEXT
)!!


I created a form for entering/editing employees. Using one TIB_Query and one
TIB_Datasource, I tied them to a TIB_Grid on one side of the form for
selecting employees (read-only grid) and edit (TIB_Edit, etc) controls on
the other side of the form.

Here is the SQL for the TIB_Query:

SELECT ID
, EMPNUM
, FIRSTNAME
, LASTNAME
, MI
, STREET1
, STREET2
, CITY
, STATE
, ZIPCODE
, HOMEPHONE
, HIREDATE
, TERMINATIONDATE
, COMMENT
FROM EMPLOYEE
ORDER BY LASTNAME, FIRSTNAME, MI

RequestLive is set to true and the KeyLinks property is set to ID and
everything updates, deletes, inserts just fine. The only problem is the
calculated field for displaying the full name. I have the CalculateAllFields
set to true just to force calculating whenever any field changes. (Do I
understand this property right?)

The CalculatedFields property holds the following:

FULLNAME VARCHAR(45)

The OnCalculateField procedure is :

procedure TfrmWorkers.WorkersCalculateField(Sender: TIB_Statement;
ARow: TIB_Row; AField: TIB_Column);
begin
if Assigned(AField) then
if (AField.FieldName = 'FULLNAME') then begin
AField.AsString := Workers.FieldByName('FirstName').AsString + ' ' +
Workers.FieldByName('MI').AsString + ' ' +
Workers.FieldByName('LastName').AsString;
WorkerGrid.Update; // not sure if this is needed...
end;
end;


When I first open the form, the grid does not show the full names of the
employees. If you click on the blank rows, the information shows up in the
TIB_Edits to the right, but the full name won't show in the grid until you
actually change a field, or tab into/out of one of the name fields. I have
an OnExit handler for them that calls the TIB_Query.CalculateFields. If I
close the query and reopen the query (for instance, to change the sort order
of the grid), the full names in the grid disappear again.

Surely this must be something simple that I am doing wrong or not setting
some property or other.

BTW, I have just downloaded IBObjects within the last 2 weeks so it should
be the latest version, IB 4.3 Aa, I believe.

Not to disappoint anyone else, but I'm rooting for Helen to figure this out
since she's so smart with these types of problems. :)

Woody (TMW)