limiting New Record Based On Records On A Specific Date

twitchie

Registered User.
Local time
Today, 09:58
Joined
Jan 16, 2003
Messages
41
Hello all. I have a simple database out there in use for registering participants in a class. The folks running the class would now like to limit the participants to 45 for a given day the class is given. Basically, they don't want to register more than 45 people for a class. So, how do I prevent a new record being entered if there are already 45 people registered for the class that day? DCount in the date of class Before Update field? Something else? When the user enters the form, the default date is the system date. The instructor then changes the date, if needed, to the date of the class s/he is registering participants for. I'd like an edit to appear telling the instructor the class size limit has been reached and prevent the addition of a new participant if the instructor attempts to register a new participant when n=45. Many thanks in advance!
 
In the Before Update event of the form, you will test using this construct:
Code:
If Nz(DCount([COLOR=Red]...[/COLOR]), 0) = 45 Then
    Cancel = True
    Msgbox "You have registered 45 for the day"
End If
Your DCount needs to take into account today's Date and the class Id. So see what you can come up with. Here's a link on the DCount() function:

http://www.techonthenet.com/access/functions/domain/dcount.php
 

Users who are viewing this thread

Back
Top Bottom