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

If 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. I am a system admin by trade so this is a new area for me and any help would be great. Thank
 
Looking into it a little more when I pull the CoCS in the code.Frontpay on the report that is when it brings the error up.

So what I did I first was returned a len on the field that has blanks. Then in the report when I was calling the the function I said:

Code:
=code.frontpay(Fields!lenofCoCS.Value, Fields!CS.Value, 
Iif(Fields!lenofCoCS.Value = 0, 0, Fields!CoCS.Value))

And the changed the function as follows:

Code:
Function FrontPay ( LenofCoCS AS integer, CS AS Integer, 
CoCS AS Integer)
	If  LenofCoCS = 0  then
		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

To bad I can't give star to myself ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top