Lost Focus Problem (1 Viewer)

Local time
Tomorrow, 02:11
Joined
Jul 12, 2006
Messages
70
Good day!

I used this code on the lost focus event. There's a problem with it. Could someone please assist me...


Private Sub Deduct_LostFocus()

If Deduct.Value < 2000 And Classification.Value = Passenger_Car Then
Deductible.Value = 2000
Else
Deductible.Value = [Coverage] * 0.005
End If

If Deduct.Value < 3000 And Classification.Value = Commercial_Vehicle Then
Deductible.Value = 3000
Else
Deductible.Value = [Coverage] * 0.005
End If

End Sub


Thank you!

Sheila
 

Bat17

Registered User.
Local time
Today, 19:11
Joined
Sep 24, 2004
Messages
1,687
I guess that it is because you second if will over write your first one, try
Code:
If Deduct.Value < 2000 And Classification.Value = Passenger_Car Then
    Deductible.Value = 2000
ElseIf Deduct.Value < 3000 And Classification.Value = Commercial_Vehicle Then
    Deductible.Value = 3000
Else
    Deductible.Value = [Coverage] * 0.005
End If

this would probably be better in the afterupdate event of deduct rather than lostfocus

HTH

Peter
 
Local time
Tomorrow, 02:11
Joined
Jul 12, 2006
Messages
70
Hi Peter!

I did exactly what you suggested, but it has no effect on the Deductible field. Any more ideas?

Thank you!

Sheila
 

Bat17

Registered User.
Local time
Today, 19:11
Joined
Sep 24, 2004
Messages
1,687
probably needs quotes, I missed that :(
Code:
If Deduct.Value < 2000 And Classification.Value = "Passenger_Car" Then
    Deductible.Value = 2000
ElseIf Deduct.Value < 3000 And Classification.Value = "Commercial_Vehicle" Then
    Deductible.Value = 3000
Else
    Deductible.Value = [Coverage] * 0.005
End If

Peter
 

Users who are viewing this thread

Top Bottom