A calculated field and a Master/Detail relationship

From: Frank (iuesei_at_virgilio.it)
Date: 12/28/03

  • Next message: Frank: "Re: Define a property to pass an array"
    Date: Sun, 28 Dec 2003 10:24:05 GMT
    
    

    In a table containing books titles I want to add a calculated field Author,
    coming from another table. I have the AuthorID that ties the two tables, so
    I thought I could use the Master/Detail relationship in the OnCalc routine,
    but I couldn't make it work. It shows the first author for all records.
    This is what I did:
    1) I established the Master Detail relationship:
         with AuthorsTable do begin
           close;
           MasterSource:= BooksDS;
           MasterFields:= 'ID_AUTHOR'; //this field in the BOOKSTable matches
    the ID field in the AUTHORTable
           indexname:= 'IDX';
           Open;
         end;
    2) In the OnCalc routine (I named cAuthor the calculated field):
        BooksTablecAuthor.Value := AuthorTable.FieldByName('AUTHOR').AsString;

    Is there a reason why the Master/Detail relationship doesn't work in this
    case or did I made something wrong which I don't realize ?


  • Next message: Frank: "Re: Define a property to pass an array"