Home » Developer & Programmer » Forms » How to auto populate a 2nd form from another form by using Global variable (Oracle 9i forms)
How to auto populate a 2nd form from another form by using Global variable [message #309502] Thu, 27 March 2008 13:49 Go to next message
sqlstar_student
Messages: 42
Registered: November 2007
Member
I created a form which contains 2 text items
userid
Password

runtime the user will be prompted to enter the details and press(SUBMIT)push button

There is a when button pressed trigger in which

The validation code where it verifies the userid & password is correct or not
Then iam capturing the userid into a global variable

:global.z := :block1.userid(:block_name.item_name) the entered value in userid at runtime
then a new_form(.....)

There is a 2nd form user Details which open when i press submit
In that form there is a text item userid

I want it to be auto populate when i press SUBMIT in 1 form

so I wrote in 2nd form When_new_form trigger

declare
z varchar2(100);
Begin
set_block_property('Block2',default_where,'userid='''||:global.z||'' ');
end;

But its not populating

Thanks for the time to read and answer
Re: How to auto populate a 2nd form from another form by using Global variable [message #309508 is a reply to message #309502] Thu, 27 March 2008 14:09 Go to previous messageGo to next message
Kaeluan
Messages: 179
Registered: May 2005
Location: Montreal, Quebec
Senior Member
There is 2 way to do that
1- using global with code like that
In the button on your master form
:GLOBAL.userid := :block1.userid;

In your called form in your when-new-form-instance
('Block2',default_where,'userid='''||global.userid||'' ');


2- You can do it using parameter between your 2 forms (Personnaly i prefer this solution)
In your master form on your button
declare
  pl_id PARAMLIST;
  pl_name VARCHAR2(10);
BEGIN
  pl_name :=  'temp';
  pl_id :=  get_parameter_list(pl_name);
  IF NOT ID_NULL(pl_id) THEN
    destroy_parameter_list(pl_id);
  END IF;
  pl_id := create_parameter_list(pl_name);

  add_parameter(pl_id, 'P_USERID', TEXT_PARAMETER, name_in('block1.P_USERID'));

  new_form('detail', TO_SAVEPOINT, NO_QUERY_ONLY, NO_SHARE_LIBRARY_DATA, pl_id);

END;

In your called form, create parameter p_userid
and in your when-new-form-instance
set_block_property('Block2',default_where,'userid='''||parameters.p_userid||'' ');


Reason why i don`t recommand global is when you have many form that need to pass parameters, it can cause many problem like where this global is initialize or is this global name used somewhere else


hope it help

[Updated on: Thu, 27 March 2008 14:13]

Report message to a moderator

Re: How to auto populate a 2nd form from another form by using Global variable [message #309775 is a reply to message #309508] Fri, 28 March 2008 14:18 Go to previous messageGo to next message
sqlstar_student
Messages: 42
Registered: November 2007
Member
Thanks a lot for the 2nd idea

But could anyone explain why the 1st one i.e populating by using a global variable is not working as i was asked to use a global variable

Am i doint it right

Iam using in 1st form

:global.z=:bloack_name.item_name

2nd form where Global.z has to be called

declare

z varchar2(1000);

Begin

set_block_property('Block2',default_where,'userid='''||:global.z||'' ');
end;

Is there anything wrong in this cause the item is not being populated in 2nd form
Re: How to auto populate a 2nd form from another form by using Global variable [message #309776 is a reply to message #309502] Fri, 28 March 2008 14:24 Go to previous messageGo to next message
Kaeluan
Messages: 179
Registered: May 2005
Location: Montreal, Quebec
Senior Member
What exactly is not working,
1- your query return nothing?
or
2- Your query does not execute?

maybe you can try adding this line after set_block_property
message(get_bloc_property('block2',DEFAULT_WHERE);

This will allow you to see what is the value in your default where clause

Re: How to auto populate a 2nd form from another form by using Global variable [message #309782 is a reply to message #309776] Fri, 28 March 2008 15:12 Go to previous messageGo to next message
solisdeveloper
Messages: 48
Registered: March 2008
Location: Mexico
Member
Ok.
Try doing this

On your master Form, in the "When-Button-Pusshed" Built-In wrtite:
:global.z=:block_name.item_name;


Then on the Detail Form in the "When-New-Form-Instance" you can do the following:

DECLARE
  v_Where VARCHAR2(2000);
BEGIN
  v_Where := 'userid = ' || :GLOBAL.z;
  set_block_property ('block2', DEFAULT_WHERE,v_Where);
  go_block ('block2');
  execute_query;
END;


That should do, and if it doesn't then can you please specify how it's not working?
Regards!

[Updated on: Fri, 28 March 2008 15:14]

Report message to a moderator

Re: How to auto populate a 2nd form from another form by using Global variable [message #309787 is a reply to message #309776] Fri, 28 March 2008 15:48 Go to previous messageGo to next message
sqlstar_student
Messages: 42
Registered: November 2007
Member
Thanks 4 the reply

I put a
when new form instance
message(:global.z);
message(:global.z);
declare ....

begin ...
set_block_property...
execute_query;
end;

in when new form instance of the 2nd query where z should return the value

and it is showing that z holds the value but
it just isnt displaying i.e it is not transferring the value from z to userid item in 2nd form

Ill try what you suggested
by inserting
v_where :='userid = '||:global.z;
and
go_block('block_nmame');
Re: How to auto populate a 2nd form from another form by using Global variable [message #309799 is a reply to message #309782] Fri, 28 March 2008 20:40 Go to previous messageGo to next message
amdabd
Messages: 91
Registered: November 2007
Location: My Computer
Member
hi;
DECLARE
  v_Where VARCHAR2(2000);
BEGIN
  v_Where := 'userid = ' || :GLOBAL.z;
  set_block_property ('block2', DEFAULT_WHERE,v_Where);
  go_block ('block2');
  execute_query;
END;
the previous code didn't work ,I'm working on a similar situation for the last 4 hours, however it still useless
& I still waiting
Re: How to auto populate a 2nd form from another form by using Global variable [message #311219 is a reply to message #309502] Thu, 03 April 2008 14:27 Go to previous messageGo to next message
Kaeluan
Messages: 179
Registered: May 2005
Location: Montreal, Quebec
Senior Member
Hi,
just something i am thinking, don`t forget to put the ' in your query if the global value is a string

v_Where := 'userid = ' || :GLOBAL.z;


may need to be like this if it's a string
v_Where := 'userid = ' || ''' ||:GLOBAL.z || ''';


Re: How to auto populate a 2nd form from another form by using Global variable [message #311221 is a reply to message #311219] Thu, 03 April 2008 14:39 Go to previous messageGo to next message
solisdeveloper
Messages: 48
Registered: March 2008
Location: Mexico
Member
Kaeluan wrote on Thu, 03 April 2008 14:27

may need to be like this if it's a string
v_Where := 'userid = ' || ''' ||:GLOBAL.z || ''';



That's true, but you can not use it like that, you have to use chr (39) to represent the apostrophe, well at least in Forms 6i, wich is the version I use.

This is how my code looks like:

v_Where := 'userid = ' || chr(39) || ':global.z' || chr(39);


Regards!
Re: How to auto populate a 2nd form from another form by using Global variable [message #311392 is a reply to message #311221] Fri, 04 April 2008 06:32 Go to previous messageGo to next message
athar.fitfd@hotmail.com
Messages: 193
Registered: October 2007
Location: pakistan
Senior Member
user forms parameters .

and change the where clause of the second form according to parameter coming from first form.

use
set_block_property('blk_name',where_clause,'enter your where clause here');
Re: How to auto populate a 2nd form from another form by using Global variable [message #311583 is a reply to message #309502] Fri, 04 April 2008 20:12 Go to previous messageGo to next message
amdabd
Messages: 91
Registered: November 2007
Location: My Computer
Member
hi,
on the 1st form set a global variable
i.e:
on dept form
begin
	:global.p_deptno := :dept.deptno;
	call_form('emp.fmx');
end;
on th 2nd form emp form
(WHEN-NEW-FORM-INSTANCE) --
BEGIN
  go_block ('emp');
  execute_query;
END;
at block emp --( block property)
set the( where clause) to
deptno=	:global.p_deptno

Re: How to auto populate a 2nd form from another form by using Global variable [message #313209 is a reply to message #311583] Fri, 11 April 2008 01:30 Go to previous message
sridhar_kallepalli
Messages: 1
Registered: April 2008
Junior Member
Hi do the following it will work

1) In the first form in when-button-pressed trigger write the following

:global.user_id :=:block_name.field_name;

2) In 2nd form in when-new-form-instance

:block_name.field_name := :global.user_id ;


regards
Sridhar

:lol:
Previous Topic: list items
Next Topic: *** data transfer from .txt file to table ***
Goto Forum:
  


Current Time: Thu Dec 05 16:17:59 CST 2024