Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2003
    Posts
    2

    Angry Unanswered: 2 way relation Master-Detail

    Hi,

    I'm using form 6.0. I have a form that containt two blocks: Dept and Emp. I made a relation form Dept (Master) to Emp (detail) cause a Dept can have more than one Emp.

    What I want is to be able to query a Dept and then fetch child record but also, I want to be able to query all the Emp and then when the user select a Emp record, the form automaticly fetch the correct Dept in the Dept block. Then. if a user make a change in the Dept block, the form post the change correctly.

    I try to make 2 relation but that 's not working.

    Can you help me whit this?

    Regards,
    Jean-Francois

  2. #2
    Join Date
    Jun 2003
    Location
    Tokyo
    Posts
    1

    Re: 2 way relation Master-Detail

    Hi,

    How about making one more table that contains conbinations between DEPT and EMP ?

    CREATE TABLE DEPT_EMP_MAP (
    DEPT_NO xxx,
    EMP_NO xxx,
    CONSTRAINT PK_DEPT_EMP_MAP PRIMARY KEY(DEPT_NO, EMP_NO),
    CONSTRAINT FK_DEPT_NO FOREIGN KEY(DEPT_NO)
    REFERENCES DEPT(DEPT_NO),
    CONSTRAINT FK_EMP_NO FOREIGN KEY(EMP_NO)
    REFERENCES EMP(EMP_NO)
    );

    Originally posted by jfrondeau
    Hi,

    I'm using form 6.0. I have a form that containt two blocks: Dept and Emp. I made a relation form Dept (Master) to Emp (detail) cause a Dept can have more than one Emp.

    What I want is to be able to query a Dept and then fetch child record but also, I want to be able to query all the Emp and then when the user select a Emp record, the form automaticly fetch the correct Dept in the Dept block. Then. if a user make a change in the Dept block, the form post the change correctly.

    I try to make 2 relation but that 's not working.

    Can you help me whit this?

    Regards,
    Jean-Francois

  3. #3
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: 2 way relation Master-Detail

    Originally posted by jfrondeau
    Hi,

    I'm using form 6.0. I have a form that containt two blocks: Dept and Emp. I made a relation form Dept (Master) to Emp (detail) cause a Dept can have more than one Emp.

    What I want is to be able to query a Dept and then fetch child record but also, I want to be able to query all the Emp and then when the user select a Emp record, the form automaticly fetch the correct Dept in the Dept block. Then. if a user make a change in the Dept block, the form post the change correctly.

    I try to make 2 relation but that 's not working.

    Can you help me whit this?

    Regards,
    Jean-Francois
    You cannot do that with the standard Forms relations: they require you to always query the master block before you can query the detail block.

    You would have to build your own code to support this. Create the Dept and Emp blocks without any relations. Then add triggers on each block to coordinate them as you want, i.e. (1) whenever new Dept record is selected, re-query the matching Emp records; (2) whenever Emp record is selected, re-query the matching Dept record.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •