Code

  • Thread starter Thread starter Bostwick
  • Start date Start date
B

Bostwick

Guest
I am trying to set a minimum charge, however I have had no luck. Here is what I want, if the LBS are < 34000 and the mrt < 40 then the total = $154.00 + everything else. The code will explain further:
If txtPounds < 34000 And mrt < 41 Then
txtTotal = 154 + (txtStops - 1) * 10 + txtAddExpense + txtMileageCharge + (txtMiles_RT * 0.0697)
Else
txtTotal = txtMileRate * (txtPounds / 2000) + (txtStops - 1) * 10 + txtAddExpense + txtMileageCharge + (txtMiles_RT * 0.0697)
End If
 
How about this?

IIf([LBS] < 34000 AND [MRT] < 40, [Something]+[Something]+154,[Someting]*[Something]+[Something])

I think you need to use the Iif Statement.

Format
IIf(Condition, If meets Condition, Else This Value)
 
I have tried this and keep getting a compile error: Argument not optional
 
Try to convert the textboxes into the appropriate data type.

txtTotal.value = 154 + (clng(txtStops.value) - 1) * 10 + txtAddExpense + clng(txtMileageCharge.value) + (clng(txtMiles_RT.value) * 0.0697)
Else
txtTotal.value = clng(txtMileRate.value) * (clng(txtPounds.value) / 2000) + (clng(txtStops.value) - 1) * 10 + clng(txtAddExpense.value) + clng(txtMileageCharge.value) + (clng(txtMiles_RT.value) * 0.0697)
End If

I converted all value in text boxes to long. You have to change that so it reflects your data types.

The text property is the default for text boxes. For this sort of situation is better to use the value property (you do not have problem with the focus of the control).
 
Thank you all for the tips and info, everything is finally working good!!
 

Users who are viewing this thread

Back
Top Bottom