Spoony
02-28-2018, 03:24 AM
Hi
I have spent many hours trying this with no luck.
I have a number of labels (8) which get filled in correctly (by dbl clicking in a Listbox) and are formatted in the following way
Format(NewOrderForm.Controls("PurPrice1").Caption, "#,###.##") - (there is also PurPrice2,3,4...8)
This is also multiplied by the value in a text box.
This all works fine, however, I'm trying to keep a running total in another label whenever the "Qty" textbox is changed.
I can get it to work without the formatting but I really need to have the formatting as 1,234.56. The VAL function I found out, will not accept the comma.
This is what I have so far. I'm sure there are cleverer ways of doing this but I'm just a novice (and self taught).
Private Sub Qty1_Change()
Dim LngTotalValue, P1, P2 As Double
If NewOrderForm.Qty1.Text = "" Then
NewOrderForm.Controls("TotalPrice1").Caption = ""
Else
NewOrderForm.Controls("TotalPrice1").Caption = Format(NewOrderForm.Controls("PurPrice1").Caption, "#,###.##") * Val(NewOrderForm.Controls("Qty1").Text)
End If
NewOrderForm.TotalPrice1.Caption = Format(NewOrderForm.TotalPrice1.Caption, "#,###.##")
NewOrderForm.Lb_TotalValue.Caption = Val(NewOrderForm.Controls("TotalPrice1").Caption) + _
Val(NewOrderForm.Controls("TotalPrice2").Caption) + _
Val(NewOrderForm.Controls("TotalPrice3").Caption) + _
Val(NewOrderForm.Controls("TotalPrice4").Caption) + _
Val(NewOrderForm.Controls("TotalPrice5").Caption) + _
Val(NewOrderForm.Controls("TotalPrice6").Caption) + _
Val(NewOrderForm.Controls("TotalPrice7").Caption) + _
Val(NewOrderForm.Controls("TotalPrice8").Caption)
NewOrderForm.Lb_TotalValue.Caption = Format(NewOrderForm.Lb_TotalValue.Caption, "#,###.##")
End Sub
Any help would be appreciated.
Thanks
Steve
I have spent many hours trying this with no luck.
I have a number of labels (8) which get filled in correctly (by dbl clicking in a Listbox) and are formatted in the following way
Format(NewOrderForm.Controls("PurPrice1").Caption, "#,###.##") - (there is also PurPrice2,3,4...8)
This is also multiplied by the value in a text box.
This all works fine, however, I'm trying to keep a running total in another label whenever the "Qty" textbox is changed.
I can get it to work without the formatting but I really need to have the formatting as 1,234.56. The VAL function I found out, will not accept the comma.
This is what I have so far. I'm sure there are cleverer ways of doing this but I'm just a novice (and self taught).
Private Sub Qty1_Change()
Dim LngTotalValue, P1, P2 As Double
If NewOrderForm.Qty1.Text = "" Then
NewOrderForm.Controls("TotalPrice1").Caption = ""
Else
NewOrderForm.Controls("TotalPrice1").Caption = Format(NewOrderForm.Controls("PurPrice1").Caption, "#,###.##") * Val(NewOrderForm.Controls("Qty1").Text)
End If
NewOrderForm.TotalPrice1.Caption = Format(NewOrderForm.TotalPrice1.Caption, "#,###.##")
NewOrderForm.Lb_TotalValue.Caption = Val(NewOrderForm.Controls("TotalPrice1").Caption) + _
Val(NewOrderForm.Controls("TotalPrice2").Caption) + _
Val(NewOrderForm.Controls("TotalPrice3").Caption) + _
Val(NewOrderForm.Controls("TotalPrice4").Caption) + _
Val(NewOrderForm.Controls("TotalPrice5").Caption) + _
Val(NewOrderForm.Controls("TotalPrice6").Caption) + _
Val(NewOrderForm.Controls("TotalPrice7").Caption) + _
Val(NewOrderForm.Controls("TotalPrice8").Caption)
NewOrderForm.Lb_TotalValue.Caption = Format(NewOrderForm.Lb_TotalValue.Caption, "#,###.##")
End Sub
Any help would be appreciated.
Thanks
Steve