Need case statement & currency math help

Punice

Registered User.
Local time
Today, 14:26
Joined
May 10, 2010
Messages
135
I have a 2007 form with two controls: 'Wages' where I enter an amount; and 'FedWH' which I want to be calculated & appear in that field when I enter a 'wage' amount. This is the VBA that uses the Fed Tax values for wages between the applicable wage ranges:

Dim Wages As Currency
Dim FedWH As Currency
Select Case Wages
Case 0# >= 1252#
[FedWH] = (([Wages] - 508) * 0.1)
Case 1252# >= 3529#
[FedWH] = (([Wages] - 756) * 0.15)
Case 3529# >= 7829#
[FedWH] = (([Wages] - 1865.2) * 0.25)
Case 7829# >= 15779#
[FedWH] = (([Wages] - 2504.18) * 0.28)
Case 5779# >= 33704#
[FedWH] = (([Wages] - 4515.52) * 0.33)
Case 33704# >= 33842#
[FedWH] = (([Wages] - 6183.43) * 0.35)
End Select
 
Try this type of thing:

Case < 1253
Case < 3530
 
I guess I didn't state my request for help clearly enough. (1) Which field do I associate the event procedure 'On-Click' with:?; (2) Are the 'Dim' s required?;
(3) Are the Case statement's correctly written for the ranges?; (4) and, are the expressions correct what I'm trying to do? In other words, what should my code be??? I only ask for help after much trying.
 
1) At what point do you want the calculation to occur? That will determine the event(s).
2) No, not if you want to refer to form controls. You could use Me.Wages
3 & 4) No; it should look like what I posted in post 2. The code will use the first case that is true, so you can evaluate them in a logical order that uses that fact.

More on 1:

http://www.baldyweb.com/FirstVBA.htm
 
Initially, I didn't understand what your first response actually meant. Per your second one, I did and applied it successfully. So simple...it's nice to see that there still are people on this planet who can think and do. tnx much & stay well!
 

Users who are viewing this thread

Back
Top Bottom