Control Source Question

G

Guest

I have a form(MainForm) that has 4 subforms(Subform1,-4), I would like to
add a text box in each subform that will give me a running total of records
in that subform where Textbox(strEmailSent) is = Yes (This is a checkbox). I
then want to take each one of those totals from each subform and create a
textbox in the main form that will add all the subforms totals together. I
can't figure out what to put in the control source to make it do what I want.

Thanks...
 
A

Allen Browne

1. Open the first subreport in design view.

2. If you don't see a Form Footer section, then click Form Header/Footer on
the View menu. (You can set the Visible property of this section to No if
you don't want to see it.)

3. In the Form Footer, add a text box, and set properties like this:
Control Source = - Sum([strEmailSent])
Format General Number
Name txtEmailSentCount
This assumes your subform has a yes/no field named strEmailSent, and you
want to count the number of Yeses.

4. Test. Save. Close. Repeat for other subforms.

5. Open the main form in design view.

6. Add a text box with Control Source of:
=[Subform1].[Form]![txtEmailSentCount]

7. Test. You can then add a plus sign, and similar expressions that refer to
the other subforms.

This will produce #Error if your subforms have no records to match, and they
are set up such that you cannot add new records. In this case, the Detail
section goes completely blank, and referring to the non-existent controls in
the subform generates an error. More info about this situation:
http://allenbrowne.com/casu-20.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

"Professional_in_need_of help"
 

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