Link to home
Start Free TrialLog in
Avatar of liberty crown
liberty crown

asked on

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

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).
Avatar of Mlanda T
Mlanda T
Flag of South Africa image

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.
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.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.