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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Environment - Sql?

Status
Not open for further replies.

vbjohn

Programmer
Aug 23, 2001
67
US
I have a question. I was wondering if there is a way that I could do something like a CASE Statement in the Data Environment. I know you can do a CASE Statement in SQL but CASE is not supported in VB Data Environment. This really bugs me. Cause I got something that I need but I could not work around it. Here is part of my SQL Code. If you know any other way to take care of this please let me know....


SELECT RTRIM(UPR00100.LASTNAME) + ', ' + RTRIM(UPR00100.FRSTNAME) AS NAME, UPR40900.DEDUCTON, UPR40900.DSCRIPTN, UPR00100.EMPLOYID, PerC = CASE UPR40900.DEDUCTON WHEN '20LEGP' THEN '9%' THEN '20UNCL' THEN '4%' ELSE '' END FROM UPR00100 INNER JOIN UPR00500......etc.....


Thanks,
John-
 
The SELECT CASE syntax in VB is :-

Select Case variable
Case instance
statement
Case instance
statement
.... etc
End Select

eg.
Select case rs!UPR40900.DEDUCTON
Case "20LEGP"
x = "9%"
Case "20UNCL"
x = "4%"
Case Else
End Select
Where x is a variable to hold the result of the condition met by the case.
rs! is the recordset returned by the SQL Select statement.

Hope this serves as a pointer to what you wish to achieve.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top