Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Calculated Field?
Thu, Oct 31 2019 9:01 PMPermanent Link

Ian Branch

Avatar

Hi Team,
Don't know if this is EDB or Delphi.
I have two tables in Master-Detail.
I am trying to add a column into the EDBTable for the Master that shows the Name field from the Detail table so it can be seen in the Master DBGrid.
I have set up a Calculated field per all the instructions, including the assignment of the Detail.Name into the Master.Calcfield in the OnCalc event of the Master table.
There must be something else I have to do because the displayed data in the look up column is not at all related to the relevant record in the Master.



Attachments: Screenshot_2.jpg
Thu, Oct 31 2019 9:03 PMPermanent Link

Ian Branch

Avatar

Pressed Post too soon. Frown
What have I missed in setting this up please?
Regards & TIA.
Ian



Attachments: Screenshot_1.jpg
Fri, Nov 1 2019 4:03 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Ian

>Don't know if this is EDB or Delphi.
>I have two tables in Master-Detail.
>I am trying to add a column into the EDBTable for the Master that shows the Name field from the Detail table so it can be seen in the Master DBGrid.
>I have set up a Calculated field per all the instructions, including the assignment of the Detail.Name into the Master.Calcfield in the OnCalc event of the Master table.
>There must be something else I have to do because the displayed data in the look up column is not at all related to the relevant record in the Master.

From what you've posted I think the problem is Ian Smiley

I have two possibilities:

1.
It looks like you're misunderstanding master-detail and calculated fields. The master-detail relationship means that the detail table will be scrolled to maintain synchronisation with the master table based on whatever relationship you defined when setting up the master-detail link. Calculated fields are calculated in the OnCalcFields event so you'd need to do something like mastertablefield.asstring := detailtablefield.asstring,.

Alternatively you can forget the calculated field and set the datasource / dataset for the display component to the right table ie the detail table & field

2.
Since you don't show enough detail it could be the persistent vs non-persistent field issue. If you've declared persistent fields for the other columns but not the calculated one - it won't show.

Roy
Fri, Nov 1 2019 5:00 AMPermanent Link

Ian Branch

Avatar

Hi Roy,
   1.   Yep.  Did that.
   2.   Don't know.

   News.  Suspecting something, not sure what, I loaded and rebuilt the
project in D2007.  Took a few changes, i.e. getting rid of a few 'vcl.'
around the place, and it all worked.
   Ah Ha! thinks I.  I have a fall back.
   I then copied the whole project back to the D10.3.2 directory and
rebuilt it, and now it all works as expected.
   Ummm.  What the!!.
   Bottom line, I have what I set out to achieve.  Don't really know what
changed but it works.

Ian
Image