R
Rachel
Hi there,
I am trying to get a text box (txtsubtotal) to sum 8 other 'price' text
boxes (txtprice1...txtprice8) when a command button (cmdCalculate) is
clicked. Each 'price' text box is filled via a combo box (cboitem1) change
code.
Here is briefly what I have:
Each combo box is coded like this:
Private Sub cboItem1_change()
Me.txtprice1 = WorksheetFunction.VLookup(Me.cboItem1, Worksheets
_("Pizzas").Range("A:B"), 2, 0)
End Sub
Each 'price' text box is coded like this:
Private Sub txtprice1_change()
txtprice1.Value = Format(Me.txtprice1.Value, "$#,##0.00")
End Sub
And the command button click is:
Private Sub cmdCalculate_Click()
If IsNumeric(Me.txtprice1.Value) _
And IsNumeric(Me.txtprice2.Value) _
And IsNumeric(Me.txtprice3.Value) _
And IsNumeric(Me.txtprice4.Value) _
And IsNumeric(Me.txtprice5.Value) _
And IsNumeric(Me.txtprice6.Value) _
And IsNumeric(Me.txtprice7.Value) _
And IsNumeric(Me.txtprice8.Value) Then
Me.txtSubTotal.Value = CDbl(Me.txtprice1.Value) _
+ CDbl(Me.txtprice2.Value) _
+ CDbl(Me.txtprice3.Value) _
+ CDbl(Me.txtprice4.Value) _
+ CDbl(Me.txtprice5.Value) _
+ CDbl(Me.txtprice6.Value) _
+ CDbl(Me.txtprice6.Value) _
+ CDbl(Me.txtprice7.Value) _
+ CDbl(Me.txtprice8.Value)
End If
End Sub
However it seems to work only sometimes. At the moment when I click
cmdCalculate when the form is 'live' nothing happens at all. It has worked
before though. It seems when I get a run-time error on any different
unrelated code it stuffs this one up.
What am I missing?
Thanks in advance
I am trying to get a text box (txtsubtotal) to sum 8 other 'price' text
boxes (txtprice1...txtprice8) when a command button (cmdCalculate) is
clicked. Each 'price' text box is filled via a combo box (cboitem1) change
code.
Here is briefly what I have:
Each combo box is coded like this:
Private Sub cboItem1_change()
Me.txtprice1 = WorksheetFunction.VLookup(Me.cboItem1, Worksheets
_("Pizzas").Range("A:B"), 2, 0)
End Sub
Each 'price' text box is coded like this:
Private Sub txtprice1_change()
txtprice1.Value = Format(Me.txtprice1.Value, "$#,##0.00")
End Sub
And the command button click is:
Private Sub cmdCalculate_Click()
If IsNumeric(Me.txtprice1.Value) _
And IsNumeric(Me.txtprice2.Value) _
And IsNumeric(Me.txtprice3.Value) _
And IsNumeric(Me.txtprice4.Value) _
And IsNumeric(Me.txtprice5.Value) _
And IsNumeric(Me.txtprice6.Value) _
And IsNumeric(Me.txtprice7.Value) _
And IsNumeric(Me.txtprice8.Value) Then
Me.txtSubTotal.Value = CDbl(Me.txtprice1.Value) _
+ CDbl(Me.txtprice2.Value) _
+ CDbl(Me.txtprice3.Value) _
+ CDbl(Me.txtprice4.Value) _
+ CDbl(Me.txtprice5.Value) _
+ CDbl(Me.txtprice6.Value) _
+ CDbl(Me.txtprice6.Value) _
+ CDbl(Me.txtprice7.Value) _
+ CDbl(Me.txtprice8.Value)
End If
End Sub
However it seems to work only sometimes. At the moment when I click
cmdCalculate when the form is 'live' nothing happens at all. It has worked
before though. It seems when I get a run-time error on any different
unrelated code it stuffs this one up.
What am I missing?
Thanks in advance