R
Rachel
Hi again,
I have a command button (cmdsubtotal) which adds 8 text boxes. I got the
following code from a post a few weeks ago and it works perfectly - thank you!
Private Sub cmdsubtotal_Click()
Dim MyTotal As Double
MyTotal = 0
If IsNumeric(Trim(Me.txtprice1.Value)) Then
MyTotal = MyTotal + Trim(Me.txtprice1.Value)
End If
If IsNumeric(Trim(Me.txtprice2.Value)) Then
MyTotal = MyTotal + Trim(Me.txtprice2.Value)
End If
If IsNumeric(Trim(Me.txtprice3.Value)) Then
MyTotal = MyTotal + Trim(Me.txtprice3.Value)
End If
If IsNumeric(Trim(Me.txtprice4.Value)) Then
MyTotal = MyTotal + Trim(Me.txtprice4.Value)
End If
If IsNumeric(Trim(Me.txtprice5.Value)) Then
MyTotal = MyTotal + Trim(Me.txtprice5.Value)
End If
If IsNumeric(Trim(Me.txtprice6.Value)) Then
MyTotal = MyTotal + Trim(Me.txtprice6.Value)
End If
If IsNumeric(Trim(Me.txtprice7.Value)) Then
MyTotal = MyTotal + Trim(Me.txtprice7.Value)
End If
If IsNumeric(Trim(Me.txtprice8.Value)) Then
MyTotal = MyTotal + Trim(Me.txtprice8.Value)
End If
Me.txtSubTotal.Value = MyTotal
End Sub
No I have added some check boxes which disable the corresponding text box
when ticked.
How can I adjust the code above to NOT include the text box value if it has
been disabled?
Thanks in advance
I have a command button (cmdsubtotal) which adds 8 text boxes. I got the
following code from a post a few weeks ago and it works perfectly - thank you!
Private Sub cmdsubtotal_Click()
Dim MyTotal As Double
MyTotal = 0
If IsNumeric(Trim(Me.txtprice1.Value)) Then
MyTotal = MyTotal + Trim(Me.txtprice1.Value)
End If
If IsNumeric(Trim(Me.txtprice2.Value)) Then
MyTotal = MyTotal + Trim(Me.txtprice2.Value)
End If
If IsNumeric(Trim(Me.txtprice3.Value)) Then
MyTotal = MyTotal + Trim(Me.txtprice3.Value)
End If
If IsNumeric(Trim(Me.txtprice4.Value)) Then
MyTotal = MyTotal + Trim(Me.txtprice4.Value)
End If
If IsNumeric(Trim(Me.txtprice5.Value)) Then
MyTotal = MyTotal + Trim(Me.txtprice5.Value)
End If
If IsNumeric(Trim(Me.txtprice6.Value)) Then
MyTotal = MyTotal + Trim(Me.txtprice6.Value)
End If
If IsNumeric(Trim(Me.txtprice7.Value)) Then
MyTotal = MyTotal + Trim(Me.txtprice7.Value)
End If
If IsNumeric(Trim(Me.txtprice8.Value)) Then
MyTotal = MyTotal + Trim(Me.txtprice8.Value)
End If
Me.txtSubTotal.Value = MyTotal
End Sub
No I have added some check boxes which disable the corresponding text box
when ticked.
How can I adjust the code above to NOT include the text box value if it has
been disabled?
Thanks in advance