How to make constraint when putting records into Access table? (1 Viewer)

vinh0105

New member
Local time
Tomorrow, 00:38
Joined
Sep 29, 2014
Messages
1
I am developing a simple database for students to register courses using Microsoft Access 2010. I have 4 tables: Student, Register, Course, and Section (1 Course can have many Sections).

Then, there is a criteria that a student can only take up to 6 courses. Hence, may I know that where and how can I include this constraint? I believe that it should be in the Macro (Before Change) of the table Register, but I have no idea about it.

My relationship is: Student -> Register <- Section <- Course

Please help me with that! Thanks in advance :)
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 17:38
Joined
Jul 9, 2003
Messages
16,269
I wouldn't know how to do it with a macro.

With VBA I would have a form with a combo box on it in which I selected the student. I would also have a button on this form called "btnNewCourse". In the after update event of the combobox, I would run an SQL statement that returned the number of courses the student was taking. If this number was 6, then I would set the "Enabled" property of the combo "btnNewCourse" to false. It would now appear grey and unclickable preventing the addition of more courses.
 

Users who are viewing this thread

Top Bottom