Total Textbox Values on a form

Z

zSplash

I have 3 textboxes on my form (with counts from my database) I have a 4th
(unbound) textbox to show the total of the values of the 3 textboxes. I
tried, as the controlSource for tbx4:
=tbx1 + tbx2 + tbx3
=tbx1.value + tbx2.value + tbx3.value
=sum(tbx1.value + tbx2.value + tbx3.value)

Each gives an error. On a form, how do I total the values from three
textboxes in a 4th textbox?

TIA
 
J

Jeff Boyce

We aren't there. We can't see your PC. We have no idea what error you
received. If you'll post the error message, maybe that will help in
diagnosing what's happening.

Even though you have an expression (say, your first one) as the
ControlSource for tbx4, Access may not understand that it is supposed to
recalculate after each/every change in tbx1, tbx2 and/or tbx3.

You could try putting something like:
Me.Recalc
in the AfterUpdate event of each of those three textboxes.

You could also try a different approach ... in the AfterUpdate event of each
of the three textboxes, you could add something like:
Me!tbx4 = Nz(Me!tbx1,0) + Nz(Me!tbx2,0) + Nz(Me!tbx3,0)

Note the use of the Nz() function to force a Null to be 0 instead. If you
have Null values, they "propagate" (something plus Null always equals Null).

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
J

Jeff Boyce

Access displays #Name when the spelling of the field/control does not match
something it knows about.

Spelling counts!

Regards

Jeff Boyce
Microsoft Office/Access MVP
 

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