adding up values in text boxes

  • Thread starter jbennett via AccessMonster.com
  • Start date
J

jbennett via AccessMonster.com

i have about 14 text boxes i need to add up when i hit a button and then the
total will be displayed in another text box. so i created the botton then put
in code and i declared variables like this:

dim rg1 as integer

rg1 = txtrg1.text

i do that for all 14 boxes but when i run it it's say that i need focus on
control or something for it to work. i was wondering if anyone can help me
out. thanks. if you need more info just let me know.
 
J

jbennett via AccessMonster.com

nevermind i realized i needed to use .value
i have about 14 text boxes i need to add up when i hit a button and then the
total will be displayed in another text box. so i created the botton then put
in code and i declared variables like this:

dim rg1 as integer

rg1 = txtrg1.text

i do that for all 14 boxes but when i run it it's say that i need focus on
control or something for it to work. i was wondering if anyone can help me
out. thanks. if you need more info just let me know.
 
F

fredg

i have about 14 text boxes i need to add up when i hit a button and then the
total will be displayed in another text box. so i created the botton then put
in code and i declared variables like this:

dim rg1 as integer

rg1 = txtrg1.text

i do that for all 14 boxes but when i run it it's say that i need focus on
control or something for it to work. i was wondering if anyone can help me
out. thanks. if you need more info just let me know.

In Access, it is a control's Value property, not it's Text property,
you need to sum.
See VBA help.

[Total] = Nz([Control1]) + Nz([Control2]) + [Nz([Control3]) + etc.

While you're in VBA help, look up the Nz function as well.
 
J

jbennett via AccessMonster.com

thank you very much.
i have about 14 text boxes i need to add up when i hit a button and then the
total will be displayed in another text box. so i created the botton then put
[quoted text clipped - 7 lines]
control or something for it to work. i was wondering if anyone can help me
out. thanks. if you need more info just let me know.

In Access, it is a control's Value property, not it's Text property,
you need to sum.
See VBA help.

[Total] = Nz([Control1]) + Nz([Control2]) + [Nz([Control3]) + etc.

While you're in VBA help, look up the Nz function as well.
 

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