How to auto populate a 2nd form from another form by using Global variable [message #309502] |
Thu, 27 March 2008 13:49 |
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 |
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 |
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 #309782 is a reply to message #309776] |
Fri, 28 March 2008 15:12 |
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 |
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 #311221 is a reply to message #311219] |
Thu, 03 April 2008 14:39 |
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!
|
|
|
|
|
|