Is there a way to sum up the values of textboxes that are not visible by default

liberty crown
liberty crown used Ask the Experts™
Hi Experts. I have three textboxes which only show when a button is checked then subsequently the values in the text boxes are summed up. My existing solution is returning empty using   ![Bill] = Nz((Me.txtPharmAmt1 + Me.txtPharmAmt2+ Me.txtPharmAmt3), 0).
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
That looks fine, though I think you want to do the Nz check on each one.
Nz(Me.txtPharmAmt1, 0) + Nz(Me.txtPharmAmt2, 0) + Nz(Me.txtPharmAmt3, 0)

Open in new window

It shouldn't matter whether the control is visible or not.
Dale FyeOwner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010

You might want to just do that in the Query which is the RowSource of your form, rather than including a field in the table that can be computed from other values in the table.

The disadvantage of doing what you are doing is that if someone makes a change to the PharmAmt1, PharmAmt2, or PharmAme3 column while working in a table, the [Bill] field will not get updated.  Another alternative, would be to make [Bill] a computed field in the table design so that no matter where those other values are changed, table, query, form, the [Bill] amount would automatically be recalculated.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial