This topic is locked

Limits

11/12/2006 8:22:05 PM
ASPRunnerPro General questions
L
lililpz@hotmail.com author

I am working on an online class registration prg. and I need to be able to limit the number of students registered per class to 16 students. How can I do this? any ideas?
<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=3838&image=1&table=forumtopics' class='bbc_emoticon' alt=':unsure:' />

D
dlangham 11/13/2006

You could have a table named "class_names" with fields called "class_id", "class_name" and "class_amount" which the "class_amount" field will hold the total amount of students allowed, in this case 16.
Then when a new record is added using a "look up dropdown box", subtract 1 off the total until 16 records have been added, once this reaches zero you could have it that the class name vanishes from the "drop down list" so its not available for selection.
Add Page

Function BeforeAdd(dict)
strSQLInsert ="UPDATE class_names SET class_amount=(class_amount-1) WHERE class_name ='"&dict("YourDropdownField")&"'"
dbConnection.Execute strSQLInsert
BeforeAdd = True

End Function


List Page

Function BeforeDelete(where)
str = "select Battle_Date from class_names where" & where

Set rsTemp = server.CreateObject("ADODB.Recordset")

rsTemp.open str, dbConnection
strSQLInsert ="UPDATE class_names SET class_amount=(class_amount+1) WHERE class_name ='"&rsTemp("YourDropdownField")&"'"

dbConnection.Execute strSQLInsert

BeforeDelete = True

End Function


Your drop down box would need something like this in the "Where" option.

"class_amount>=1"


This is only a sample.