Home » Developer & Programmer » Forms » Validate Multiple Record Block.
Validate Multiple Record Block. [message #202009] Tue, 07 November 2006 17:24 Go to next message
Messages: 1
Registered: November 2006
Junior Member
Hello every body-

Would appreciate your inputs as to how to go about doing this.

I have a multi record block like below.
SEQ #   THEMES                    PICK
1      THEME 1
2      THEME 2
3      THEME 3
4      THEME 4
5      THEME 5
6      THEME 6

The 'PICK' field is a check box, that the user will click on if he needs to select a particular 'THEME'.

I need to do the following validations ( I will be having a button something like INSERT BUTTON) at the bottom of the multi column block.

.. Only 3 THEMES are to selected.
.. If less than 3 THEMES are selected, need to show an alert stating that at least 3 THEMES can be selected.
.. If more than 3 THEMES are selected, need to show an alert stating that only 3 THEMES can be selected, allow the user to change selections.
.. If only 3 THEMES are selected, need to insert the selected THEMES into a table.

For example, in the above situation, if the user picks 'THEMES' with SEQ# 2,4,5; then I need to insert the SEQ #, along with the other primary key (which is STUDENT ID) into the table.

Would really appreciate if any one could let me know how to do this.

Thanks for your time..

[Updated on: Tue, 07 November 2006 22:43] by Moderator

Report message to a moderator

Re: Validate Multiple Record Block. [message #202035 is a reply to message #202009] Tue, 07 November 2006 22:59 Go to previous message
Messages: 10180
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Like many things in Forms there is nearly always more than one way to do something.

You have your block containing 'themes' ('themes'). You do not need to display the 'seq #'. Have another block called 'ctrl' (a non-database 'control' block) and create an item called 'cnt' (count - make it numeric). Against your block 'themes' create a trigger 'Pre-Query' that sets ':ctrl.cnt' to zero, and a trigger 'When-Checkbox-Changed' that tests whether the checkbox is set 'on' or 'off' and either increments or decrements ':ctrl.cnt'.

In your 'Insert' button test the current value of ':ctrl.cnt' and give any messages that are required.

To put the data out to the database, use the 'first_record' command to get to the top of the block and then test each record to see whether you need to use it in an 'insert' statement to the database. You could populate another table so that Forms can manage the commit behaviour but most students don't worry about that sort of thing until they find that the 'commit_form' didn't do anything. That's because the form does not see the inserts into the database. Use the 'standard.commit' command instead. Back to our block scan, test if the record is the 'last_record' and if it is not, then do a 'down' command' and continue your loop.

Please don't ask how each of these commands work. Read the Forms documentation (get the PDF version for easier searching) or search this forum.

Previous Topic: Forms Documentation.
Next Topic: Making Initcaps
Goto Forum:

Current Time: Thu Aug 17 03:06:26 CDT 2017

Total time taken to generate the page: 0.08466 seconds