Home » Developer & Programmer » Forms » TEXT_PARAMETER can not be used ; PARAMETER_ATTR
TEXT_PARAMETER can not be used ; PARAMETER_ATTR [message #660262] Mon, 13 February 2017 11:22 Go to next message
IneedYourHelp
Messages: 27
Registered: January 2017
Junior Member
Hi,

I have table A in two Forms 1 and 2. When someone presses a button, I want to display the data he saw in table A in Forms 1, in table A in Forms 2 (I know it is not an realistic example having the same table twice..).


create table A (
X int primary key,
Y varchar(50),
Z varchar(50)
);

Form 1
When-Button-Pressed Trigger


DECLARE
pl_id ParamList;
pl_name varchar(9) := 'DATA';
begin
pl_id := get_parameter_list(pl_name);
if ID_NULL(pl_id) THEN
pl_id := create_parameter_list(pl_name);
else
destroy_parameter_list(pl_id);
pl_id := create_parameter_list(pl_name);
end if;
add_parameter(pl_name,'X_PARA',TEXT_PARAMETER,:A.X);
call_form('FORM2.fmx');
end;



Form 2
New-Form-Instance-Trigger


declare
X_OLD varchar(50);
begin
GET_PARAMETER_ATTR('DATA','X_PARA',TEXT_PARAMETER,X_OLD);

select X, Y, Z
into :A.X, :A.Y , :A.Z
from A where X_OLD=A.X;
end;


When I try to compile the New-Form-Instance-Trigger I get an error-message like:
TEXT_PARAMATER can not be used.
It refers to TEXT_PARAMETER in GET_PARAMETER_ATTR.

How can I solve this ?


Thanks in advance.


[EDITED by LF: fixed topic title typo]

[Updated on: Wed, 15 February 2017 15:10] by Moderator

Report message to a moderator

Re: TEXT_PARAMATER can not be used ; PARAMETER_ATTR [message #660263 is a reply to message #660262] Mon, 13 February 2017 11:26 Go to previous messageGo to next message
cookiemonster
Messages: 13961
Registered: September 2008
Location: Rainy Manchester
Senior Member
You don't need to use get_parameter_attr at all. You need to create parameters with the correct name and type under the parameters node in object explorer. You can then refer to them same as datablock items:

select X, Y, Z
into :A.X, :A.Y , :A.Z
from A where :parameter.x_para = A.X;

You really should be using execute_query to populate the form, not a select.
Re: TEXT_PARAMATER can not be used ; PARAMETER_ATTR [message #660266 is a reply to message #660263] Mon, 13 February 2017 14:17 Go to previous messageGo to next message
Littlefoot
Messages: 21823
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Alternatively, you could set a global variable in Form A, call Form B, modify Form B's data block WHERE clause in order to use the global variable, execute_query in Form B's WHEN-NEW-FORM-INSTANCE trigger. Should be relatively simple (I'm not saying it is better; I prefer parameters over global variables).
Re: TEXT_PARAMATER can not be used ; PARAMETER_ATTR [message #660282 is a reply to message #660266] Tue, 14 February 2017 02:27 Go to previous messageGo to next message
IneedYourHelp
Messages: 27
Registered: January 2017
Junior Member
Thanks for your help!

How would I do


select X, Y, Z
into :A.X, :A.Y , :A.Z
from A where X_OLD=A.X;


with execute_query instead?
I'm sorry, I'm still a beginner.


go_block('A')
....
execute_query;

Thanks.
Re: TEXT_PARAMATER can not be used ; PARAMETER_ATTR [message #660286 is a reply to message #660282] Tue, 14 February 2017 03:41 Go to previous messageGo to next message
cookiemonster
Messages: 13961
Registered: September 2008
Location: Rainy Manchester
Senior Member
Set the where clause of the block to :a.x = :parameter.x_para.
Execute_query.

That's it.
Re: TEXT_PARAMATER can not be used ; PARAMETER_ATTR [message #660291 is a reply to message #660286] Tue, 14 February 2017 04:18 Go to previous messageGo to next message
IneedYourHelp
Messages: 27
Registered: January 2017
Junior Member
When I do that, Forms asks me if I want to save. If I choose 'no', it works but I dont want to have this question.
I tried commit; (to save) and exit_form (to leave query mode, but it exits the form, so I guess I'm not in some query mode) in the trigger, but both did not work.
How can I solve this?

Thanks.
Re: TEXT_PARAMATER can not be used ; PARAMETER_ATTR [message #660292 is a reply to message #660291] Tue, 14 February 2017 04:24 Go to previous messageGo to next message
cookiemonster
Messages: 13961
Registered: September 2008
Location: Rainy Manchester
Senior Member
Stop populating datablock items before executing the query.
Re: TEXT_PARAMATER can not be used ; PARAMETER_ATTR [message #660301 is a reply to message #660292] Tue, 14 February 2017 07:10 Go to previous messageGo to next message
IneedYourHelp
Messages: 27
Registered: January 2017
Junior Member
I don't know how to do this.

Let's say form 1 has a button with

BUTTON-PRESSED-TRIGGER
new_form('Form2.fmx');

Form 2 has a

WHEN-NEW-FORM-INSTANCE-TRIGGER

:A.X := 1; /* X is primary key */
Execute_query;


How can I stop populating datablock A before I do my stuff?
Re: TEXT_PARAMATER can not be used ; PARAMETER_ATTR [message #660307 is a reply to message #660301] Tue, 14 February 2017 08:01 Go to previous messageGo to next message
cookiemonster
Messages: 13961
Registered: September 2008
Location: Rainy Manchester
Senior Member
By deleting the line of code that assigns a value to :a.x. It's not doing anything useful. It's not going to be used by the query, you would need to go into enter-query mode first, or do that assignment in pre-query instead.

I've already told you what you need, but I'll repeat:

Set the where clause property of the datablock, in it's property palette to:
x = :parameter.<name of parameter>

Then have WNFI issue execute_query.
That's all you need.
You don't need or want to copy the parameter to a datablock item.
Re: TEXT_PARAMATER can not be used ; PARAMETER_ATTR [message #660381 is a reply to message #660307] Wed, 15 February 2017 10:07 Go to previous messageGo to next message
IneedYourHelp
Messages: 27
Registered: January 2017
Junior Member
Thanks this works now.

But I still have the original problem, because I am not sure your suggestion with parameters works. They dont seem to be global, each modul has its own parameters.
Re: TEXT_PARAMATER can not be used ; PARAMETER_ATTR [message #660382 is a reply to message #660381] Wed, 15 February 2017 10:14 Go to previous messageGo to next message
cookiemonster
Messages: 13961
Registered: September 2008
Location: Rainy Manchester
Senior Member
You want to pass a value from one form to another. Doing that is the only thing parameters exist for.
So why wouldn't my suggestion work?
Re: TEXT_PARAMATER can not be used ; PARAMETER_ATTR [message #660418 is a reply to message #660382] Thu, 16 February 2017 02:29 Go to previous messageGo to next message
IneedYourHelp
Messages: 27
Registered: January 2017
Junior Member
How would you do it?

One Form can't find the parameter of the other one.
How can I pass it without a parameterlist?
Re: TEXT_PARAMATER can not be used ; PARAMETER_ATTR [message #660424 is a reply to message #660418] Thu, 16 February 2017 03:37 Go to previous messageGo to next message
cookiemonster
Messages: 13961
Registered: September 2008
Location: Rainy Manchester
Senior Member
I'm confused about how you're confused.
Have you read the form builder help topics on parameters?
They have full examples.
Re: TEXT_PARAMATER can not be used ; PARAMETER_ATTR [message #660426 is a reply to message #660424] Thu, 16 February 2017 04:34 Go to previous messageGo to next message
IneedYourHelp
Messages: 27
Registered: January 2017
Junior Member
IN FORM A I have a button where I set value to a parameter and I have new_form(FORMB);
In FORM B I am not able to get the value of the Parameter in Form A by :PARAMETER.PARAMETER_IN_FORMA.
Re: TEXT_PARAMATER can not be used ; PARAMETER_ATTR [message #660427 is a reply to message #660426] Thu, 16 February 2017 04:37 Go to previous messageGo to next message
cookiemonster
Messages: 13961
Registered: September 2008
Location: Rainy Manchester
Senior Member
Looking at the original code - you need to specify the parameter list as a parameter to call_form.
Have a look at the call_form topic in form builder help.
Re: TEXT_PARAMATER can not be used ; PARAMETER_ATTR [message #660431 is a reply to message #660427] Thu, 16 February 2017 06:04 Go to previous messageGo to next message
IneedYourHelp
Messages: 27
Registered: January 2017
Junior Member
Thank you so much. Passing parameters works now.

But I still have one problem.
After I executed the query with the where condition in the property palette, I want to remove this condition to use the datablock like usual.

In my new-form-Instance-trigger I have written:

execute_query;
set_block_property('Name of my Datablock',DEFAULT_WHERE,'');

But it does not work.
Re: TEXT_PARAMATER can not be used ; PARAMETER_ATTR [message #660434 is a reply to message #660431] Thu, 16 February 2017 06:21 Go to previous messageGo to next message
cookiemonster
Messages: 13961
Registered: September 2008
Location: Rainy Manchester
Senior Member
use get_block_property to check what default_where is after you set it.
Then use get_block_property to get the last_query property after you execute a second query to see what it did.
Re: TEXT_PARAMATER can not be used ; PARAMETER_ATTR [message #660466 is a reply to message #660434] Fri, 17 February 2017 10:35 Go to previous message
IneedYourHelp
Messages: 27
Registered: January 2017
Junior Member
It worked.

When I set the property in the GUI it didnt work to reset it, when I set it with set_block_property it works.
I didnt know that there is a difference.
Thanks.
Previous Topic: Making Foreign Keys Human readable
Next Topic: EMAIL RELATED ISSUE IN WINDOW 10 64 BIT MACHINE .
Goto Forum:
  


Current Time: Sun Dec 22 07:14:06 CST 2024