TheElephantMan
Programmer
Hi, all.
I have a function that I'm using to take null fields (such as the result of a left join) and convert them into zero. Here's my code:
The problem is that when I run it on a column that contains null data, I get "#ERROR" in the null fields, not a zero. A little insight into what I'm doing wrong would be GREATLY appreciated.
Thanks,
TEM
I have a function that I'm using to take null fields (such as the result of a left join) and convert them into zero. Here's my code:
Code:
'this function is designed to return an integer zero (0)
'if passed a null string: ("") or (null). It will return the
'original value if not null
Function returnZeroOnNull(stringIn As String) As String
'create variable to hold the return value
Dim returnValue As String
'assign default value
returnValue = stringIn
'if the input was/is null, then
If returnValue = Null Or returnValue = "" Then
'prepare to return a zero
returnValue = "0"
End If
'return value
returnZeroOnNull = returnValue
The problem is that when I run it on a column that contains null data, I get "#ERROR" in the null fields, not a zero. A little insight into what I'm doing wrong would be GREATLY appreciated.
Thanks,
TEM