Forum Moderators: coopster & phranque

Message Too Old, No Replies

Validating a value before insert

how can i prevent an invalid value?

         

maxxtraxx

7:20 pm on May 25, 2003 (gmt 0)

10+ Year Member



i have a input form that has a list/menu for users to select an integer (1-7) for scheduling a certain amount of people for a specific time. this works great right now, but the problem is that only a certain amount of ppl can be scheduled for any one time.

my question is how can i prevent a user from inserting a new record and then going back and adding more (updating that record) values beyond a specific limit?

for example: the maximum number for this date/time is 7, but currently i do not have a way to limit this, so another user can enter a new record and enter a value (say, 3) which would then make the number scheduled 10.

is there a validation i can script that would chk the database and calculate that the limit has been exceeded?

so, the data entry person would receive an error/popup message that would inform them that the max.limit has been exceeded and they cannot enter more values for this date/time.

any help would be greatly appreciated.

thanks!

daisho

7:39 pm on May 25, 2003 (gmt 0)

10+ Year Member



Yes.

Just to a select statememnt. Most likely using the SUM() Sql function. Make sure the return result + the selected amount is <= 7.

To get even slicker do a validation before sending the pulldown box. If the sum is currently 5 only have 1 and 2 in the pulldown box.

daisho.

maxxtraxx

7:52 pm on May 25, 2003 (gmt 0)

10+ Year Member



excellent! should i just create a seperate query for this or try to incorporate it from one of my existing ones?

daisho

9:41 pm on May 25, 2003 (gmt 0)

10+ Year Member



Which ever way you feel is best :)