[RESOLVED] Sum function using Combobox data
I have 3 textboxes and 1 combobox.
txtpresence = calculated via other textboxes
txtProduction = enters by user
cboScore = 0 -25 selected by user
txtEfficiency = populated with summation result
Code:
Private Sub txtPresence_Change()
If Me.txtPresence.Value <> vbNullString Then
If IsNumeric(Me.txtPresence.Value) = True Then
If Me.txtProduction.Value <> vbNullString Then
If IsNumeric(Me.txtProduction.Value) = True Then
If Me.cboScore.Value <> vbNullString Then
If IsNumeric(Me.cboScore.Value) = True Then
Me.txtEfficiency.Value = [CDbl(Me.txtProduction.Value) / CDbl(Me.txtPresence.Value) * 75] + CDbl(Me.cboScore.Value)
End If
End If
End If
End If
End If
End If
End Sub
Private Sub txtProduction_Change()
If Me.txtProduction.Value <> vbNullString Then
If IsNumeric(Me.txtProduction.Value) = True Then
If Me.txtPresence.Value <> vbNullString Then
If IsNumeric(Me.txtPresence.Value) = True Then
If Me.cboScore.Value <> vbNullString Then
If IsNumeric(Me.cboScore.Value) = True Then
Me.txtEfficiency.Value = [CDbl(Me.txtProduction.Value) / CDbl(Me.txtPresence.Value) * 75] + CDbl(Me.cboScore.Value)
End If
End If
End If
End If
End If
End If
End Sub
Private Sub cboScore_Change()
If Me.cboScore.Value <> vbNullString Then
If IsNumeric(Me.cboScore.Value) = True Then
If Me.txtPresence.Value <> vbNullString Then
If IsNumeric(Me.txtPresence.Value) = True Then
If Me.txtProduction.Value <> vbNullString Then
If IsNumeric(Me.txtProduction.Value) = True Then
Me.txtEfficiency.Value = [CDbl(Me.txtProduction.Value) / CDbl(Me.txtPresence.Value) * 75] + CDbl(Me.cboScore.Value)
End If
End If
End If
End If
End If
End If
End Sub
It gives error on this line for cboScore declaration
Code:
Me.txtEfficiency.Value = [CDbl(Me.txtProduction.Value) / CDbl(Me.txtPresence.Value) * 75] + CDbl(Me.cboScore.Value)
Should i use another term instead of CDbl(Me.cboScore.value) or there's something else wrong in my code?
Re: Sum function using Combobox data
Quote:
CDbl(Me.cboScore.value)
should be fine, as long as the combobox value is a valid numeric value
what error do you get?
Re: Sum function using Combobox data
I shouldn't use brackets in code .i just replaced brackets with parentheses