Textbox adding problem
Hey Rob, this is your code
I have 22 Product Types. You select the product from the ComboBox. When
you select the product, all the textboxes auto populate. Each product has 3
textboxes. One is Number of Units, next is Unit Cost, next is Unit Sale.
Every product has these textboxes and these 3 text boxes have direct impact
over profit. In each of these 3 textbox change events I put the code
CalculateProfit so it will call that procedure from the module. The module
contains this code below. My problem is when I select multiple products,
textbox 119 does not add the textboxes up, it just keeps adding the price
into the textbox. For example, one product I select has a profit of $30,
the next has a profit of $40, instead of textbox 119 displaying $80, it
displays $30$40. This pattern continues. Why is this happening? Is it
happening because the code is in the change event for each product so the
code calculates it up individual? I would like for it to add it so $80
displays.
Sub CalculateProfit()
Dim strTemp as String
strTemp = OrderForm.TextBox9.Value + OrderForm.TextBox14.Value +
OrderForm.TextBox19.Value + OrderForm.TextBox24.Value + _
OrderForm.TextBox29.Value + OrderForm.TextBox34.Value +
OrderForm.TextBox39.Value + OrderForm.TextBox44.Value + _
OrderForm.TextBox49.Value + OrderForm.TextBox54.Value +
OrderForm.TextBox59.Value + OrderForm.TextBox64.Value + _
OrderForm.TextBox69.Value + OrderForm.TextBox74.Value +
OrderForm.TextBox79.Value + OrderForm.TextBox84.Value + _
OrderForm.TextBox89.Value + OrderForm.TextBox94.Value +
OrderForm.TextBox99.Value + OrderForm.TextBox104.Value + _
OrderForm.TextBox109.Value + OrderForm.TextBox114.Value
OrderForm.TextBox119.Value = Replace(strTemp, "Select", "")
End Sub
|