-
Mar 4th, 2017, 05:39 AM
#1
Thread Starter
Member
[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?
-
Mar 4th, 2017, 06:32 PM
#2
Re: Sum function using Combobox data
should be fine, as long as the combobox value is a valid numeric value
what error do you get?
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Mar 8th, 2017, 02:25 AM
#3
Thread Starter
Member
Re: Sum function using Combobox data
I shouldn't use brackets in code .i just replaced brackets with parentheses
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|