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

SQL statement not working as wanted

Status
Not open for further replies.

Catrina

Programmer
Feb 11, 2000
70
US
I am using Access with a VB project. I am creating Queries to help with reports.

I have employee totals stored in a table as strings(I have to store them this way to be compatable with the program the totals are tranmitted to). Negative numbers are stored as 00500-. When summing these I need to look for the - and change that total into a negative. I have tried using an IIF statement, but I get a false returned evey time. Here is part of my SQL statement:

IIf((Right([EmployeeHours].[AdjToNet],1)="-"),(0 Val([EmployeeHOurs].[AdjToNet])),
[EmployeeHours].[AdjToNet]) AS adjToNet

Does Access not understand the right,left, mid commands? I get no errors, the statement is just not working correctly. Any suggestions?

Thanks

Catrina
 
try this

IIf(Right([EmployeeHours].[AdjToNet],1)="-",-1* Val([EmployeeHours].[AdjToNet]),Val([EmployeeHours].[AdjToNet])) AS Adjusted

PaulF
 
or you might use

CDbl([EmployeeHours].[AdjToNet]) AS adjToNet

instead of the if construct.


Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top