I have a total field on a subform, calculated by summing 2 fields on the main form. My subform is divided into 2 sections (Primary and Secondary) the user selects whether it is a primary or secondary option on the main form by clicking on a checkbox (which then updates a field on the subform "txtSecondary" with an ID, which if the checkbox is not checked is blank).
Depending on this choice, I want the total to either appear in the Primary total, or the Secondary total on my subform. This is where I begin to run into problems, and I can't figure out why. My total is based on 2 unbound text boxes on the main form, these 2 text boxes are completed using a calculation from 2 further subforms (I have 3, the actual calculation is on the subforms, and the unbound text boxes take their data from the calculation result). If I go onto my totals subform and in the design of field txtPrimaryTotal enter the control source as =[Forms]![frmJobHeader]![txtTotalA]+[Forms]![frmJobHeader]![txtTotalB] then I get the correct total. However I want this total to either appear txtPrimaryTotal or txtSecondaryTotal depending on the outcome of a check box on the main form.
I tried putting on the after update event of the checkbox on the main form:
If chkSecondary = true then
Me!frmTotals![txtSecondaryTotal] = [Forms]![frmJobHeader]![txtTotalA]+[Forms]![frmJobHeader]![txtTotalB]
Me!frmTotals![txtPrimaryTotal] = 0
Else
Me!frmTotals![txtPrimaryTotal] = [Forms]![frmJobHeader]![txtTotalA]+[Forms]![frmJobHeader]![txtTotalB]
Me!frmTotals![txtSecondaryTotal] = 0
End If
But this does not work, I also tried changing (and moving) the If statement from the Main form onto the Totals subform's on current event, and had it as If txtSecondary = " " Then follow the statements as above. But this also does not work, no matter where I put the If statement, it would not populate the totals fields on the subform (however it did always change the Primary or Secondary total to 0 depending on the outcome). The more I think about it, the more I think it has something to do with the unbound controls on the main form. They are populated as:
Subform > Calculated Unbound Control > MainForm > Unbound Control = Calculated Unbound Control on Subform.
Should I scrap the 2 unbound controls on the main form, and in my If statement sum the 2 unbound controls on the subforms? So that it looks something like Me!frmTotals![txtSecondaryTotal] = [Forms]![frmSubform1]![txtUnboundControl1]+[Forms]![frmSubForm2]![txtUnboundControl2] The only thing I am then worried about is can I reference information on a subform from another subform? Sorry for the long post. Thanks.
Depending on this choice, I want the total to either appear in the Primary total, or the Secondary total on my subform. This is where I begin to run into problems, and I can't figure out why. My total is based on 2 unbound text boxes on the main form, these 2 text boxes are completed using a calculation from 2 further subforms (I have 3, the actual calculation is on the subforms, and the unbound text boxes take their data from the calculation result). If I go onto my totals subform and in the design of field txtPrimaryTotal enter the control source as =[Forms]![frmJobHeader]![txtTotalA]+[Forms]![frmJobHeader]![txtTotalB] then I get the correct total. However I want this total to either appear txtPrimaryTotal or txtSecondaryTotal depending on the outcome of a check box on the main form.
I tried putting on the after update event of the checkbox on the main form:
If chkSecondary = true then
Me!frmTotals![txtSecondaryTotal] = [Forms]![frmJobHeader]![txtTotalA]+[Forms]![frmJobHeader]![txtTotalB]
Me!frmTotals![txtPrimaryTotal] = 0
Else
Me!frmTotals![txtPrimaryTotal] = [Forms]![frmJobHeader]![txtTotalA]+[Forms]![frmJobHeader]![txtTotalB]
Me!frmTotals![txtSecondaryTotal] = 0
End If
But this does not work, I also tried changing (and moving) the If statement from the Main form onto the Totals subform's on current event, and had it as If txtSecondary = " " Then follow the statements as above. But this also does not work, no matter where I put the If statement, it would not populate the totals fields on the subform (however it did always change the Primary or Secondary total to 0 depending on the outcome). The more I think about it, the more I think it has something to do with the unbound controls on the main form. They are populated as:
Subform > Calculated Unbound Control > MainForm > Unbound Control = Calculated Unbound Control on Subform.
Should I scrap the 2 unbound controls on the main form, and in my If statement sum the 2 unbound controls on the subforms? So that it looks something like Me!frmTotals![txtSecondaryTotal] = [Forms]![frmSubform1]![txtUnboundControl1]+[Forms]![frmSubForm2]![txtUnboundControl2] The only thing I am then worried about is can I reference information on a subform from another subform? Sorry for the long post. Thanks.