Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code for Summing three combo box values on a Form

Status
Not open for further replies.

STRATMAN1

Programmer
Jun 17, 2004
19
0
0
US
I have a form that has four controls- the first three are combo boxes with integer values, the fourth is a text box for a total of the three combo boxes. all the controls are bound to fields in a query/table. (So that the text box with the total saves to the table). I am trying to write the code for this to create the total filling in after the combo box values are set. not sure of the procedure command, and where the event procedure should be (before or after update and on which control). The combo box fields can be cbo1, cbo2, and cbo2, and the total box name can be txttotal. all good advice appreciated!!
 
If you want to recalc the total after you change each combobox then I'd do something like

Private Sub Recalc()
txttotal = NZ(cbo1,0)+NZ(cbo2,0)+NZ(cbo3,0)+NZ(cbo4,0)
End Sub

Then in each After_Update of the comboboxes, add the line
Recalc

Example

Private sub cbo1_AfterUpdate()
Recalc
End sub

hope that helps
 
warthog72, neither ever create a procedure named like a method !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top