Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Help on Sql Query Calculation - Please

Status
Not open for further replies.

Ezyflo

Technical User
Aug 12, 2002
26
0
0
US
I have the following sql query in a database. Is there a way for me to incorporate the If Else statement in?

I have a form where the user will select their property class from a combo box and enter their amount in a text box. With that the various calculations below. I need to make the If-then-else calculation also.

The form has a calculate button with a requery macro to run it after the user enters in the information.

If I am unable to put in the sql query, how would I go about doing it in VB Code with the underlying info source from the query for calculation and have it show up in an unbound text box?

Sql:

SELECT RMVPropertyClassRates.PropertyClass, RMVPropertyClassRates.Limit, RMVPropertyClassRates.ClassRate1, RMVPropertyClassRates.ClassRate2, (Forms!RMV!txtAmount)*0.00158002 AS Q1, (Forms!RMV!txtAmount)*0.00029901 AS Q2, (Forms!RMV!txtAmount)*0.00023785 AS Q3, (Forms!RMV!txtAmount)*0.00013592 AS Q4, *
FROM RMVPropertyClassRates
WHERE (((RMVPropertyClassRates.PropertyClass)=Forms!RMV!CboPropClass));


Need this incorporated:

If [Amount] > [Limit] Then ([Amount] - [Limit]) * [ClassRate2] +( [Limit] * [ClassRate1]) * 0.23
Else
[Amount] * [Limit1]) * 0.23
End If

Any help would greatly be appreciated!

Thanks.
 
try the iif function, check help to review the syntax.

iif ([Amount] > [Limit], ([Amount] - [Limit]) * [ClassRate2] +( [Limit] * [ClassRate1]) * 0.23,
([Amount] * [Limit1]) * 0.23)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top