By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,493 Members | 1,223 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,493 IT Pros & Developers. It's quick & easy.

Null field values & isnull function

P: n/a
I have a query that has null values for some of the fields. I'd like
those fields to display a zero instead of a blank so I can do totals
on them (sum/totalling the field is not working with null values) I
created a function as follows...

Function zeros(ethfield As Integer) As Integer

If IsNull(ethfield) Then
zeros = 0
Else
zeros = ethfield
End If
End Function

I'm getting a #error for the fields with nulls, and the non-null
fields are returning the correct data. Any idea of what I'm doing
wrong or a different approach for converting the null values to zeros?

Sep 18 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Coll" <co*********@hotmail.comwrote in message
news:11**********************@57g2000hsv.googlegro ups.com...
>I have a query that has null values for some of the fields. I'd like
those fields to display a zero instead of a blank so I can do totals
on them (sum/totalling the field is not working with null values) I
created a function as follows...

Function zeros(ethfield As Integer) As Integer

If IsNull(ethfield) Then
zeros = 0
Else
zeros = ethfield
End If
End Function

I'm getting a #error for the fields with nulls, and the non-null
fields are returning the correct data. Any idea of what I'm doing
wrong or a different approach for converting the null values to zeros?
Why not use the built-in Nz function?
As in:
Nz([ethfield],0)
Fred Zuckerman
Sep 18 '07 #2

P: n/a

"Coll" <co*********@hotmail.comwrote in message
news:11**********************@57g2000hsv.googlegro ups.com...
I have a query that has null values for some of the fields. I'd like
those fields to display a zero instead of a blank so I can do totals
on them (sum/totalling the field is not working with null values) I
created a function as follows...

Function zeros(ethfield As Integer) As Integer

If IsNull(ethfield) Then
zeros = 0
Else
zeros = ethfield
End If
End Function

I'm getting a #error for the fields with nulls, and the non-null
fields are returning the correct data. Any idea of what I'm doing
wrong or a different approach for converting the null values to zeros?

You are getting a error because you defined ethfield as an Integer instead
of a Variant.
..
Sep 18 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.