Log in

View Full Version : Count total values in fields on subforms



Ringhal
03-09-2016, 03:06 AM
Hi

I need help with a Dcount function in Access, please.

I have a main form and 4 sub forms. Each subform has a field called "Status" and can have a value of either "Active" or "Ready". A combo box on the main form has those two status options. A textbox next to this combox will hold the total count I am trying to get. The record source for each subform is only one table (no query).

My idea is to get the count of the status in the subforms that match the value in the combobox. There is also a filtering field called refno that needs to be applied to the criteria (there's a refno textbox in the main form). If i get it to work with one subform then I can apply it to the others and run a total to get my required count.

So, I have:

MyFormStatusTotal = Dcount("Status","MyTable", "[refno] = Forms![MyForm]![refno] AND [status] = Forms![MyForm]![myComboBox]")

Please can some one help me?

ranman256
03-09-2016, 06:49 AM
in the subform footer, put a field to count, txtSubCount. The property "=Count([field])"
Now, in the main form , just reference that field on the form. (use the builder to pick it. it always spells it correctly)

main.txtBox = me.subform.form.txtSubCount