Home » Developer & Programmer » Forms » IMPORTANT,,how to get total records & total amount (Oracle form 6!)
IMPORTANT,,how to get total records & total amount [message #590238] Tue, 16 July 2013 03:58 Go to next message
nada_am
Messages: 9
Registered: January 2013
Location: KSA
Junior Member
Dear All,

I've a form that allow the user to enter information & save it.

in the form there is text_item called AMOUNT with multiable records.

I want when the user press SAVE button, a popup message shows the number of records enterd & total amount in all records.

EX:
AMOUNT
1000
200
3000

After clicking Save button a popup message shows ( you enterd 3 records & 4200 $ ) OK ? Cancel?
-------------

this my code in WHEN-BUTTON-PRESSED trigger

if :amount IS NOT NULL THEN

declare
cnt_record number := 1;
cnt_amount number :=:amount;


begin
go_item('amount');
first_record;

while :system.last_record = 'FALSE'
loop
cnt_record := cnt_record + 1;
cnt_amount :=cnt_amount + :amount;
next_record;
end loop;

message('There are ' || cnt_record || ' records and the total amount is'|| cnt_amount );
end;
END IF;
-----

BUT !! when I test the form nothing happend ...plzzzzzz need Help
Re: IMPORTANT,,how to get total records & total amount [message #590243 is a reply to message #590238] Tue, 16 July 2013 04:25 Go to previous messageGo to next message
Littlefoot
Messages: 21813
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Forms informs you about that by default (see status line at the bottom of the form), so - in my opinion, you don't have to do anything but point users to use what's already there.

Mentioning "save" button: which button is that? Did you create it, or is it placed in Forms built-in toolbar? If the latter, then this trigger won't do anything, that's true, because WHEN-BUTTON-PRESSED won't work with it. Whichever button it is, this code won't even save anything into the database (as it lacks COMMIT).

MESSAGE, as it is, displays information in previously mentioned status line. If you want a popup message, duplicate that MESSAGE command, i.e.
message('There are ' || cnt_record || ' records and the total amount is'|| cnt_amount );
message('There are ' || cnt_record || ' records and the total amount is'|| cnt_amount );
Alternatively, create an alert.

P.S. Forgot to mention: you don't have to loop through all records to count them; simply navigate to LAST_RECORD and :SYSTEM.CURSOR_RECORD will tell you which record it is.

[Updated on: Tue, 16 July 2013 04:28]

Report message to a moderator

Re: IMPORTANT,,how to get total records & total amount [message #590268 is a reply to message #590238] Tue, 16 July 2013 08:28 Go to previous messageGo to next message
joy_division
Messages: 4963
Registered: February 2005
Location: East Coast USA
Senior Member
What about setting the calculation property of the column?
Re: IMPORTANT,,how to get total records & total amount [message #590273 is a reply to message #590268] Tue, 16 July 2013 09:09 Go to previous messageGo to next message
jay_cooldude
Messages: 50
Registered: March 2013
Location: Hyd
Member
Mr Nada_am,

Please create a alert and do not change any property in the property pallate.

In the WHEN-BUTTON-PRESSED trigger execute the following code.
if :amount IS NOT NULL THEN

declare 
cnt_record number := 1;
cnt_amount number :=:amount;
alrt varchar2(200);
alrt2 varchar2(300);


begin
go_item('amount');
first_record;

while :system.last_record = 'FALSE' 
loop
cnt_record := cnt_record + 1;
cnt_amount :=cnt_amount + :amount;
next_record;


alrt2:='There are ' || cnt_record || ' records and the total amount is'|| cnt_amount ;
end loop;
set_alert_property('ALERT1',ALERT_MESSAGE_TEXT,alrt2);
alrt:=show_alert('ALERT1');

end;
END IF;
Re: IMPORTANT,,how to get total records & total amount [message #590278 is a reply to message #590273] Tue, 16 July 2013 10:37 Go to previous messageGo to next message
Littlefoot
Messages: 21813
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
/forum/fa/1606/0/ Uh, oh ... total amount ... didn't even notice that requirement, sorry.
Re: IMPORTANT,,how to get total records & total amount [message #590314 is a reply to message #590273] Wed, 17 July 2013 01:52 Go to previous message
nada_am
Messages: 9
Registered: January 2013
Location: KSA
Junior Member
jay_cooldude wrote on Tue, 16 July 2013 09:09
...


Thank you soooooo much guys, specially jay_cooldude ,,your code was just perfect !!

thank you all for help (:

[EDITED by LF: removed unnecessary quote of the whole message]

[Updated on: Wed, 17 July 2013 02:32] by Moderator

Report message to a moderator

Previous Topic: Multiple file selection in forms
Next Topic: Image Path save in database and image name as Design no
Goto Forum:
  


Current Time: Mon Jul 01 17:59:37 CDT 2024