Home » Developer & Programmer » Forms » Restrict number of record in Form6i
Restrict number of record in Form6i [message #637515] Tue, 19 May 2015 08:02 Go to next message
amit_garg3
Messages: 22
Registered: January 2006
Location: bangalore
Junior Member
Hi

I have a block having 12 row. I didn't want user insert in 13 row.I want to restrict it 12 row only. How to do that?
Re: Restrict number of record in Form6i [message #637517 is a reply to message #637515] Tue, 19 May 2015 09:04 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Revoke the unwanted privileges (INSERT, DELETE...) from your user.

Re: Restrict number of record in Form6i [message #637530 is a reply to message #637517] Tue, 19 May 2015 12:07 Go to previous messageGo to next message
Littlefoot
Messages: 21806
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
As it is possible to enter records anywhere in a multi record block (not only as the last record), you'll have to check how many records you already have (such as by navigating to the LAST_RECORD and checking value of the :SYSTEM.CURSOR_RECORD (review what other SYSTEM variable do as well!)) and forbid creating a record if total number of record exceeds 12.

Now, that's somewhat "stupid" as it will prevent entering more than 12 records in that block. What does it, really, mean? Do you not want to have more than 12 records in the whole table? Or more than 12 records per CLIENT_ID? Or more than 12 records per DATE_COLUMN value? Or ...? Got the point?

Therefore, if you could describe what problem you are trying to solve, someone might suggest a solution you'd be satisfied with.

[EDIT] Typo

[Updated on: Wed, 20 May 2015 00:07]

Report message to a moderator

Re: Restrict number of record in Form6i [message #637539 is a reply to message #637530] Tue, 19 May 2015 17:11 Go to previous messageGo to next message
CraigB
Messages: 386
Registered: August 2014
Location: Utah, USA
Senior Member
I agree with Littefoot. The requirement to not allow more than "X" number of records doesn't make sense to me. However, you could use either a When-Validate-Record trigger that checks the :SYSTEM.TRIGGER_RECORD or the :SYSTEM.CURSOR_RECORD and if the value > 12 then display a message to the user and halt processing by raising the Form_Trigger_Failure exception.

You could also use a block level When-Create-Record trigger, but there would be a little bit more code to halt the user here.

Craig...
Re: Restrict number of record in Form6i [message #637559 is a reply to message #637530] Wed, 20 May 2015 03:27 Go to previous messageGo to next message
amit_garg3
Messages: 22
Registered: January 2006
Location: bangalore
Junior Member
Hi

Block have 5 different column. Value's are insert for One month at a time.Month are coming automatically ie total 12 record. I do not want user insert it for 13. Right now I am using when :system.last_record, when value >12, it's goes to first record. Is there any other way to do that?
Re: Restrict number of record in Form6i [message #637562 is a reply to message #637559] Wed, 20 May 2015 04:19 Go to previous messageGo to next message
cookiemonster
Messages: 13917
Registered: September 2008
Location: Rainy Manchester
Senior Member
If it's for a given set of 12 months why not just pre-populate the records with the required months and not allow insert at all?
Re: Restrict number of record in Form6i [message #637597 is a reply to message #637562] Wed, 20 May 2015 09:44 Go to previous message
CraigB
Messages: 386
Registered: August 2014
Location: Utah, USA
Senior Member
Quote:
If it's for a given set of 12 months why not just pre-populate the records with the required months and not allow insert at all?

Agreed, this is a better approach. An alternative would also be to create a Unique Key on the table by YEAR and MONTH and then add a Check Constraint that does not allow a MONTH value > 12. This will prevent duplicate months for a given year and also prevent the insert of the month=13. Either approach would work.

Craig...
Previous Topic: Server and Client Forms having same Voucher Numbers
Next Topic: How to get record number and total record number in record indicator?
Goto Forum:
  


Current Time: Thu Mar 28 13:40:39 CDT 2024