I have created two forms one is master and other is detail .I have called detail form from master from .I want to create relationship between both forms.
Please make me solution.
Relationship Between Master and Detail Forms
-
- Posts: 615
- Joined: Mon Sep 18, 2006 1:32 am
- Location: United Arab Emirates
- Contact:
Dear Usman,
If tables used on back end of these forms have primary - foreign relation ship then you can simply create relation ship by using Data Blocks relations.You can also handle this by using different canvases(i would like to suggest "use multi canvas instead of New form".
If they don't have any relation ship but have one common (like id) then write a cursor on button trigger when_button_pressed and call form and fetch data in detail form.
Example Code
Declare
CURSOR C IS
SELECT * FROM Table_name
WHERE APPID = :Fieledname;
VAR_CUR C%ROWTYPE;
VAR_INAME VARCHAR2(100);
VAR_UNAME VARCHAR2(100);
VAR_TAX NUMBER;
VAR_DISC NUMBER;
VAR_TOT NUMBER;
BEGIN
--Open Form and Go_block
call_form(Form_name)
GO_BLOCK('Block Name');
FIRST_RECORD;
CLEAR_BLOCK;
OPEN C;
LOOP
FETCH C INTO VAR_CUR;
IF C%NOTFOUND THEN
EXIT;
END IF;
:SR := VAR_CUR.SRNO;
:INST := VAR_CUR.INSTNO;
:DUEDATE := VAR_CUR.DUEDATE;
:DUEAMT := VAR_CUR.DUEAMT;
NEXT_RECORD;
END LOOP;
CLOSE C;
FIRST_RECORD;
GO_BLOCK('Block Name');
END;
Let us Know if still have confusion / issue
If tables used on back end of these forms have primary - foreign relation ship then you can simply create relation ship by using Data Blocks relations.You can also handle this by using different canvases(i would like to suggest "use multi canvas instead of New form".
If they don't have any relation ship but have one common (like id) then write a cursor on button trigger when_button_pressed and call form and fetch data in detail form.
Example Code
Declare
CURSOR C IS
SELECT * FROM Table_name
WHERE APPID = :Fieledname;
VAR_CUR C%ROWTYPE;
VAR_INAME VARCHAR2(100);
VAR_UNAME VARCHAR2(100);
VAR_TAX NUMBER;
VAR_DISC NUMBER;
VAR_TOT NUMBER;
BEGIN
--Open Form and Go_block
call_form(Form_name)
GO_BLOCK('Block Name');
FIRST_RECORD;
CLEAR_BLOCK;
OPEN C;
LOOP
FETCH C INTO VAR_CUR;
IF C%NOTFOUND THEN
EXIT;
END IF;
:SR := VAR_CUR.SRNO;
:INST := VAR_CUR.INSTNO;
:DUEDATE := VAR_CUR.DUEDATE;
:DUEAMT := VAR_CUR.DUEAMT;
NEXT_RECORD;
END LOOP;
CLOSE C;
FIRST_RECORD;
GO_BLOCK('Block Name');
END;
Let us Know if still have confusion / issue
My requirement is that Master form is based on Dept Table and Detail form is based on Emp Table.I have two seperate forms one for Master and other for Detail.When i execute query on Master form suppose on executing query deptno 10 is displayed .When i click button to call Detail Form information should display on Detail form only against Dept No 10.I mean only against that Department which is on Master Form.
-
- Posts: 615
- Joined: Mon Sep 18, 2006 1:32 am
- Location: United Arab Emirates
- Contact:
Please check it out.I am doing like that
i have master form name DTEST that contains Dept Table Columns.
Second form is DTEST1 that contains Emp Table Columns and is in tabular form.I have a button on DTEST form and when_button_pressed
trigger i have written this code
Declare
CURSOR C IS
SELECT * FROM emp
WHERE deptno = :deptno;
VAR_CUR C%ROWTYPE;
BEGIN
call_form('e:\test\dtest1.fmx');
GO_BLOCK('emp');
FIRST_RECORD;
CLEAR_BLOCK;
OPEN C;
LOOP
FETCH C INTO VAR_CUR;
IF C%NOTFOUND THEN
EXIT;
END IF;
:EMP.EMPNO := VAR_CUR.empno;
:EMP.name := VAR_CUR.ename;
:EMP.v_job := VAR_CUR.job;
:EMP.mgr := VAR_CUR.mgr;
:EMP.hiredate:=VAR_CUR.hiredate;
:EMP.sal:=VAR_CUR.sal;
:EMP.comm:=VAR_CUR.comm;
:EMP.deptno:=VAR_CUR.deptno;
NEXT_RECORD;
END LOOP;
CLOSE C;
FIRST_RECORD;
GO_BLOCK('emp');
END;
First i execute query on master form and deptno 10 and its name and other information displays on this form.
Then I press button on master form.The error is that bad bind variable :emp.empno,:emp.name and like that.
Detail Form opens but no data is fetched on it against deptno 10
What is the problem here.
Both forms are seperate.
i have master form name DTEST that contains Dept Table Columns.
Second form is DTEST1 that contains Emp Table Columns and is in tabular form.I have a button on DTEST form and when_button_pressed
trigger i have written this code
Declare
CURSOR C IS
SELECT * FROM emp
WHERE deptno = :deptno;
VAR_CUR C%ROWTYPE;
BEGIN
call_form('e:\test\dtest1.fmx');
GO_BLOCK('emp');
FIRST_RECORD;
CLEAR_BLOCK;
OPEN C;
LOOP
FETCH C INTO VAR_CUR;
IF C%NOTFOUND THEN
EXIT;
END IF;
:EMP.EMPNO := VAR_CUR.empno;
:EMP.name := VAR_CUR.ename;
:EMP.v_job := VAR_CUR.job;
:EMP.mgr := VAR_CUR.mgr;
:EMP.hiredate:=VAR_CUR.hiredate;
:EMP.sal:=VAR_CUR.sal;
:EMP.comm:=VAR_CUR.comm;
:EMP.deptno:=VAR_CUR.deptno;
NEXT_RECORD;
END LOOP;
CLOSE C;
FIRST_RECORD;
GO_BLOCK('emp');
END;
First i execute query on master form and deptno 10 and its name and other information displays on this form.
Then I press button on master form.The error is that bad bind variable :emp.empno,:emp.name and like that.
Detail Form opens but no data is fetched on it against deptno 10
What is the problem here.
Both forms are seperate.
-
- Posts: 615
- Joined: Mon Sep 18, 2006 1:32 am
- Location: United Arab Emirates
- Contact:
Dear Usman,
First You need to get current Dept no(for Current Record where cursor and store into global variable)
you need to write this Code on when_new_form_instance trigger by passing Global variable dept no at that time of form opening
On Button you just get dept no and store it into global variable call form and pass all code on when_new_form_instance
Let Me Know in case of any issue
First You need to get current Dept no(for Current Record where cursor and store into global variable)
you need to write this Code on when_new_form_instance trigger by passing Global variable dept no at that time of form opening
On Button you just get dept no and store it into global variable call form and pass all code on when_new_form_instance
Let Me Know in case of any issue
Who is online
Users browsing this forum: No registered users and 13 guests