instructorTek
Instructor
- Jun 5, 2006
- 61
Hi all I have a combo box that is updating text boxes on a form and after the user makes their selections a button is clicked and the sum of the numbers in the text boxes are found. My problem is that although the information selected from the combo box is a number (this comes from a table), when it updates the text boxs it seems to do so as text, because when I click the button to find the sum of the numbers, I am just getting a concatenation of values rather than an addition. E.g. 2 + 2 = 22
What can I do to get the sum being performed?
Option Compare Database
Dim Cost, PriceCam, PriceCase as Single
‘The user makes a selection
Private Sub cboSelect_AfterUpdate()
txtPriceCase.SetFocus
Me![txtPriceCase].Value = Me![cboSelect].Column(3)
PriceCase = txtPriceCase.Value
Me![txtPriceCam].Value = Me![cboSelect].Column(4)
PriceCam = txtPriceCam.Value
Me.Refresh
End Sub
‘The user clicks here to find the sum
Private Sub cmdCost_Click()
txtCost.SetFocus
Cost = PriceCam + PriceCase
txtCost.Value = Cost
End Sub
What can I do to get the sum being performed?
Option Compare Database
Dim Cost, PriceCam, PriceCase as Single
‘The user makes a selection
Private Sub cboSelect_AfterUpdate()
txtPriceCase.SetFocus
Me![txtPriceCase].Value = Me![cboSelect].Column(3)
PriceCase = txtPriceCase.Value
Me![txtPriceCam].Value = Me![cboSelect].Column(4)
PriceCam = txtPriceCam.Value
Me.Refresh
End Sub
‘The user clicks here to find the sum
Private Sub cmdCost_Click()
txtCost.SetFocus
Cost = PriceCam + PriceCase
txtCost.Value = Cost
End Sub