IMPORTANT,,how to get total records & total amount [message #590238] |
Tue, 16 July 2013 03:58 |
|
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 |
|
Littlefoot
Messages: 21823 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
|
|
|
|
|
|
|