Home All Groups Group Topic Archive Search About

Require a child record (on Subform)?

Author
24 Feb 2005 6:31 PM
D. Shane Fowlkes
Hello all!

I have a simple form which also has a subform in it where child records can
be written to a child table based on the parent record/form.  I would like
to make it required that the user enter/pick at least one child record (buy
many are possible).  As it is now, it's not required.

Is there some simple attribute using Access 2003 in the form or subform I
can set to make a child record on the subform be required instead of
optional?

Think of the tables/forms like shown below  As my form is designed now,
someone could enter "Bob" in the form and never pick if he has one or more
certifications...which should be required.  Make sense?


StaffTable:
ID   |   PersonName
---------------------
1    |   Bob
2    |   John


CertificationsTable
ID   |   CertName
-----------------------
1   |   Juggling
2   |   Yoddling


CertStaffMatch
ID   |   StaffID   |   CertID
---------------------------
1   |   2     |     1
2   |   2    |   2

Author
25 Feb 2005 4:49 PM
Paul Doree
One way would be to use the dcount function.  After the user has entered the
parent data and the record has been saved, run something like the following
to see how many child records there are for the parent:

dcount("StaffID","CertificationsTable","StaffID = form.StaffID")

If 0 is returned, then no child records have been entered

Paul

Show quote
"D. Shane Fowlkes" wrote:

> Hello all!
>
> I have a simple form which also has a subform in it where child records can
> be written to a child table based on the parent record/form.  I would like
> to make it required that the user enter/pick at least one child record (buy
> many are possible).  As it is now, it's not required.
>
> Is there some simple attribute using Access 2003 in the form or subform I
> can set to make a child record on the subform be required instead of
> optional?
>
> Think of the tables/forms like shown below  As my form is designed now,
> someone could enter "Bob" in the form and never pick if he has one or more
> certifications...which should be required.  Make sense?
>
>
> StaffTable:
> ID   |   PersonName
> ---------------------
> 1    |   Bob
> 2    |   John
>
>
> CertificationsTable
> ID   |   CertName
> -----------------------
> 1   |   Juggling
> 2   |   Yoddling
>
>
> CertStaffMatch
> ID   |   StaffID   |   CertID
> ---------------------------
> 1   |   2     |     1
> 2   |   2    |   2
>
>
>
>
>

AddThis Social Bookmark Button