View Full Version : Restricting records


tilda
12-23-2002, 04:55 AM
Hi Folks
Small problem here if any one can help!

I have two tables with a one to many relationship, does anyone know how to restrict the amount of records entered on the many side. For example if we have student details on the one side, some are only allowed to take five courses, my problem is how to restrict the amount of courses on the many side. If this makes sense to anyone please let me know if it can be done.


Thanks in advance
Tilda

shay
12-23-2002, 05:13 AM
One solution is to have an integer field CourseNo in your 'many' table with validation rule '<=5'.

However, if the 'no more than 5 courses' rule only applies to some students, you'll probably need to use code to do what you want.

hth

shay :cool:

tilda
12-24-2002, 01:47 AM
Hi Shay

Thanks but unfortunately students can do different amounts of courses, but it does need to be controlled.

Tilda

ColinEssex
12-24-2002, 01:54 AM
Just thinking through this quickly - perhaps you can have a field on the student ID screen that you enter the number of courses that a student can do.

Then you can have some code (like a DCount or something) that counts up the number they have already registered for. If that number = the number they can take then don't allow the courses screen to accept any more new courses for that student.

Col
:cool:

tilda
12-24-2002, 02:23 AM
Hi Colin
Yes I can try that; the extra field is not a problem. Would I do the code in the form?

Tilda

ColinEssex
12-24-2002, 02:26 AM
That would be best

Put it in the OnCurrent property 'cos it'll have to run for every record you view.

Col
:cool:

tilda
12-24-2002, 02:47 AM
Thanks Colin
I'll give it a go
Tilda

PS Everyone have a Super Christmas