Home » Developer & Programmer » Forms » how to count checked check boxes along with their checked and unchecked conditon (forms 6i)
how to count checked check boxes along with their checked and unchecked conditon [message #569754] Thu, 01 November 2012 02:04 Go to next message
neerumishra
Messages: 6
Registered: November 2012
Location: delhi
Junior Member
hello everyone..
i want to count how many check boxes are chechked and if the check box is unchecked the count will decrease as soon as checkbox is check or uncheck.the number of chech boxes are depentdent on record set that are fetched from database....can any one help.....
Re: how to count checked check boxes along with their checked and unchecked conditon [message #569762 is a reply to message #569754] Thu, 01 November 2012 02:51 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Create a non-database item (number datatype) which will hold number of checked checkboxes (let's call it CB_CNT (checkbox count)).

What is the initial state? Is the form empty (so you are supposed to enter new records), or do you fetch them (by executing a query) from the database and then do something (insert, update, delete)?

If it is empty, initial CB_CNT value is 0 (zero); in WHEN-CHECKBOX-CHANGED trigger increase (or decrease) CB_CNT item value.

If you fetch values from the database, count checkboxes that are already checked (you can do that by looping through block records, or - using GET_BLOCK_PROPERTY (LAST_QUERY) you can even find the WHERE clause and count that number). Once you have the initial state, you're back on WHEN-CHECKBOX-CHANGED trigger option.
Re: how to count checked check boxes along with their checked and unchecked conditon [message #569765 is a reply to message #569754] Thu, 01 November 2012 03:56 Go to previous messageGo to next message
neerumishra
Messages: 6
Registered: November 2012
Location: delhi
Junior Member
hey littlefoot thanx...
can you provide me some sample code...
i am new to forms and reports..not getting..it properly..Sad
i am fetching some records..that are displaying in the block..

[Updated on: Thu, 01 November 2012 03:58]

Report message to a moderator

Re: how to count checked check boxes along with their checked and unchecked conditon [message #635491 is a reply to message #569765] Tue, 31 March 2015 01:10 Go to previous message
xxubi
Messages: 2
Registered: June 2012
Junior Member
Declare
V_Count Number := 0;
v_Record Number := :System.Cursor_Record;
Begin
First_Record;
Loop
If :Active = 'Y' Then
v_Count := V_Count+1;
End If;
Exit When :System.Last_record = 'TRUE';
Next_record;
End Loop;
Go_Record(v_Record);
if v_Count > 1 Then
Message('One Month Can Be Active at a Time');
:Active := 'N';
Raise Form_Trigger_Failure;
End If;
End;
Previous Topic: trigger error
Next Topic: problem in hierarchical tree
Goto Forum:
  


Current Time: Fri Apr 19 08:58:54 CDT 2024