URGENT --- Creating a ValidationRule which references a query

D

Daniel Jones

How do i reference a query's fields in a validation rule?

I want to make it so it stops a user from enrolling a student into a class
which is full.

i have a query which counts the current students that are enrolled in a
particular class and the size limit of that class.

HELP PLEASE!!!

Daniel
 
J

John Nurick

I doubt whether this is possible in an Access/Jet database. Even if it
is, the answer would involve cunning DDL stuff that would be out of
place in the gettingstarted newsgroup.

Instead, use code in the BeforeUpdate event procedure of the form (you
are using a form, aren't you?) to check the number of students already
enrolled, e.g. by using DCount() on your existing query or a similar
one.
 
B

Barry Gilbert

You can use any domain aggregate function (Dlookup, DSum, DCount, etc.) to
get values from a query. In your validation rule, put something like:

DSum("MyCountFieldName","MyQueryName") < 35

This says that if the sum of the values in the count field of your query
exceeds 35, fire the validation message.

HTH,
Barry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top