How check/uncheck checkbox on parent form if records do or do not exist in subform

SteveL

Registered User.
Local time
Today, 10:55
Joined
Dec 3, 2004
Messages
60
I have a parent form which has a yes/no checkbox in the form's record source. Then in that parent form I have a sub-form. If NO records exist in the sub-form I want the checkbox to be UN checked. If records DO exist in the sub-form, I want the checkbox to be CHECKED.

But I want this to happen as records are added or deleted from the sub-form. In other words, if the parent form is opened and no records exist in the subform then the checkbox should be unchecked. But as soon as the first record has been entered in the subform, the checkbox on the parent form should be checked. Likewise, as soon as the last record has been revoved from the sub-form, the checkbox on the parent form should be unchecked.

What code do I need to accomplish all of this?

Any help will certainly be appreciated.

--Steve
 
in the ONCURRENT form event

chkBox.value = Dcount("*","qsSubFormDataset") > 0

(use the query that the sub form uses. get the count)
 
I know that is a rather old post, but I am attempting to accomplish the same thing. I have records in a sub-form, if there are records in the sub-form, then check the box, otherwise clear the box. I attempted the above solution, but when it runs the query, it is showing the maximum possible records. In other words, no filtering is being done. This is a linked sub-report.

Can I add criteria to the Dcount command?
 
Never mind, figured it out (after getting an error for the criteria).
 

Users who are viewing this thread

Back
Top Bottom