How to Sum Combo Box Values

M

MB

I have a form in which 3 combo boxes hold values based upon their control
source. I would like to add a text box on my form that would be the sum of
those values. I just can't figure out the expression to add those values.
I'm using Access 2007. Thank you.
 
M

M Skabialka

On the after update event of the combos on your form have an event like
this:

Me!TextBox = Combo1.Column(0) + Combo2.Column(0) + Combo3.Column(0)

assuming that the first column in the combo query holds the data, or
Column(1) if there is a hidden ID field or something first.

Mich
 
M

MB

Thank you for your response.

I'm confused as to how this total will show in the text box. Please explain
further (I'm new at this).

I understand how to put the code in the after update of the combos, I just
don't understand how the total will appear in a separate text box.

Also, I will then need to show these totals in a report.

Thank you again so much for your help.
 
M

M Skabialka

I was assuming you already had a texbox on your form for this total, so I
called it Me!TextBox in my example. If you select Combo1, then Combo2, then
Combo3, and they all show values, and the after event of Combo 3 is as I
suggested, then Me!TextBox should show the result of adding them.

For your report, add a totals field in the query you use as the control
source. In the query designer add a new column and put in something like
this
Total: [mytable].[field1] + [mytable].[field2] + [mytable].[field3]
and use Total as a field on your report.

Mich
 

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