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

Iif working with nulls and blanks fields

Status
Not open for further replies.

GShort

MIS
Apr 20, 2005
70
US
I have a field that I am running a If statement against. Their are three way that the field state my be entered in and they are Data, Null, <Blank>. Of course I don't have any problem if their is data in the field or if it is null (I use a ifnull) but if the field is blank it return an error. I am using the following code to return the value.

Code:
Function FrontPay (CS AS integer, CoCS AS integer)
	If len(CoCS) < 1
		If CS > 599 and CS < 990
			Return "Good"
		Else
			Return "Low"
		End If
	Else If (CS > 599 or CoCS > 599) and (CS < 990 or CoCS < 990)
		Return "Good"
	Else
		Return "Low"
	END If
End Function

The CoCS is the field that is causing me the headaches also this is being used in Microsoft SQL Report Services. I am a system admin by trade so this is a new area for me and any help would be great. Thank
 
Why not simply use the IsNumeric function ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
It is not a problem identifying if it is blank or a numeric value the problem that I am running into is when it tries to see if the CoCS field is greater then 599 or less then 990.

Is there a way to tell the code to ignore the Else If (CS > 599 or CoCS > 599) and (CS < 990 or CoCS < 990) if the CoCS is blank?
 
If Not IsNumeric(CoCS) Then
If CS > 599 And CS < 990 Then
Return "Good"
Else
Return "Low"
End If
ElseIf (CS > 599 Or CoCS > 599) And (CS < 990 Or CoCS < 990) Then
Return "Good"
Else
Return "Low"
End If

anyway, the code you posted don't looks like VBScript ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top