Página 1 de 1

How to set Master - Detail Relation in Report Designer

Publicado: Dom Abr 24, 2016 7:39 am
por hemantpandya
Hi All

I am a Newbee. Just started using FRH. I want to create/design Master Detail report in Report Designer. Not sure how to relate/link field of Master & Detail. Using following code to invoke report Designer.

use depo new // <- Detail
set orde to 2
use gr new // <- Master
set orde to 1

// need to link with gr->gcode = depo->gcod

WITH OBJECT oReport := TFastReport():New()
:AddDbf( "GR", { "GR->*" } )
:AddDbf( "depo", { "depo->*" } )
:Create()
:DesignReport()
:End()
END WITH

In designer created Master & Detail Band but not sure how to link field ( gr->gcode = depo->gcod) haven't seen any Field Link Designer where I can link the field from 2 DBF.
Please Guide me.

Thanks in advance.
Hemant
Sydney-Australia

Re: How to set Master - Detail Relation in Report Designer

Publicado: Lun Abr 25, 2016 9:57 am
por ignacio
Hello,

Take a look FR sample. There are two ways to establish the master-child relation :

1) Via SET RELATION (Harbour side):

Código: Seleccionar todo

   USE .\DATA\CUSTOMER SHARED VIA "DBFCDX" NEW
   SET ORDER TO TAG "CUSTNO"
   USE .\DATA\ORDERS SHARED VIA "DBFCDX" NEW
   SET RELATION TO CustNo INTO CUSTOMER

   WITH OBJECT oReport := TFastReport():New()
      :AddDbf( "ORDERS", { "Orders->*", "Customer->*" } )
      :Create()
      :cFilename := ".\Reports\Relations2.fr3"
      IF !lDesign
         :ShowReport()
      ELSE
         :DesignReport()
      ENDIF
      :End()
   END WITH
2) Via FR:

Código: Seleccionar todo

   USE .\DATA\CUSTOMER SHARED VIA "DBFCDX" NEW
   USE .\DATA\ORDERS SHARED VIA "DBFCDX" NEW

   WITH OBJECT oReport := TFastReport():New()
      oCustomer := :AddDbf( "CUSTOMER", { "Customer->*" } )
      oOrders   := :AddDbf( "ORDERS", { "Orders->*" } )
      oOrders:SetMaster( oCustomer, {"CUSTNO=CUSTNO"} )
      :Create()
      :cFilename := ".\Reports\Relations.fr3"
      IF !lDesign
         :ShowReport()
      ELSE
         :DesignReport()
      ENDIF
      :End()
   END WITH
Regards,

Re: How to set Master - Detail Relation in Report Designer

Publicado: Lun Abr 25, 2016 12:07 pm
por hemantpandya
Hi ignacio,

Thank you very much for your guidance, much appreciated. Will try accordingly and if any issue will get back to forum.

Regards
Hemant