A family of Microsoft relational database management systems designed for ease of use.
1. I would like to know if I can use queries like course count and find course duplicates as validation rules when entering data into the form?
2. In my form there are 3 fields
- Course ID
- Section ID
- Student ID
I would like to limit the list in the second field (section ID ) based on entry in the first field (course ID)
1. You cannot call a query as the ValidationRule property of a control or column (field), but you can do so as a CHECK CONSTRAINT on the table. This cannot be done in table design view, but by executing code. For an example see this earlier thread.
2. The Section ID combo box can be correlated with the Course ID combo box by giving it a RowSource property which references the Course ID control as a parameter, e.g.
SELECT [Course ID], [Course]
FROM [Courses]
WHERE [Section ID] = Form![Section ID]
ORDER BY [Course];
The Section ID combo box is then set to Null requeried in the AfterUpdate event procedure of the Course ID combo box with:
Me.[Course ID] = Null
Me.[Course ID].Requery
and requeried in the form's Current event procedure with:
Me.[Course ID].Requery
However, this raises a modelling issue. By having both Course ID and Section ID columns in the table to which your form is bound you are introducing redundancy, because Course ID is functionally determined by Section ID. The table is consequently not normalized to Third Normal Form (3NF) which requires all non-key columns to be functionally determined solely by the whole of the table's primary key. Otherwise the table is open to the risk of update anomalies. The table should include only the Section ID column and the Course ID combo box in the form should be an unbound control. You'll find an example in ComboDemo.zip in my public databases folder at:
https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169
If you have difficulty opening the link copy its text (NB, not the link location) and paste it into your browser's address bar. In the demo the form illustrating the use of correlated combo boxes in single form view (first button on the opening menu form) is the appropriate example in your case.