Calculation

G

Guest

I created a form that has 4 text boxes. After entering numbers to these text
boxes, I would like to have the total.

Ex: Text box1=2
Text box2=3
Text box3=2
Text box4=1

Again, I would like to have the total, 8, as soon as I finish entering
numbers.
----------------------------------------

I used command button to create the button and added the Sum ([textbox1]+
………]) on the button’s property . However, it only works after I closed the
form and opened it again. I think that I have to use VBA code at After
Update, but I don’t know how to write the code. Please help.

Thanks
Chi
 
G

Guest

Are this fields bounded to fields in a table?

If they are you can use in the ControlSource of the fifth text box
=Nz([Field1],0)+Nz([Field2],0)+Nz([Field3],0)+Nz([Field4],0)

When the field1-4 are the name of the fields in the table.
The Nz used to convert Null with 0

If they are not bounded try
=Val(Nz([Field1],0))+Val(Nz([Field2],0))+Val(Nz([Field3],0))+Val(Nz([Field4],0))

When Field1-4 are the name of the text boxes
 
G

Guest

Please help. When entering =Nz(Field1],0........at the textbox's
ControSource, I always get a message " Microsoft Office Access has
encountered a problem and needs to close." So I can’t continue working on it.

Actually, I have about 30 textboxes in the form. Does the problem occur
because of many textboxes on the form?

Thanks
Chi

Chi

Ofer Cohen said:
Are this fields bounded to fields in a table?

If they are you can use in the ControlSource of the fifth text box
=Nz([Field1],0)+Nz([Field2],0)+Nz([Field3],0)+Nz([Field4],0)

When the field1-4 are the name of the fields in the table.
The Nz used to convert Null with 0

If they are not bounded try:
=Val(Nz([Field1],0))+Val(Nz([Field2],0))+Val(Nz([Field3],0))+Val(Nz([Field4],0))

When Field1-4 are the name of the text boxes
--
Good Luck
BS"D


Chi said:
I created a form that has 4 text boxes. After entering numbers to these text
boxes, I would like to have the total.

Ex: Text box1=2
Text box2=3
Text box3=2
Text box4=1

Again, I would like to have the total, 8, as soon as I finish entering
numbers.
----------------------------------------

I used command button to create the button and added the Sum ([textbox1]+
………]) on the button’s property . However, it only works after I closed the
form and opened it again. I think that I have to use VBA code at After
Update, but I don’t know how to write the code. Please help.

Thanks
Chi
 

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