Re: trying to use null but getting no where
- From: sparks <sparks@xxxxxxxxxxx>
- Date: Fri, 21 Mar 2008 16:58:41 GMT
Thanks Tom that did the trick.
I read that only variants could have null assigned to them but I did
not see what you had posted....and on a Friday too LOL
thanks again
On Fri, 21 Mar 2008 09:44:02 -0700, Tom van Stiphout
<no.spam.tom7744@xxxxxxx> wrote:
On Fri, 21 Mar 2008 15:44:00 GMT, sparks <sparks@xxxxxxxxxxx> wrote:
You're making several mistakes.
First off, in VBA only variants can be null. Integers, strings, etc.
cannot.
This is all legal:
Dim v As Variant
v = Null
v = SomeFunctionReturningNull()
v = Me.Controls(x).Value
v = myRecordset.Fields(x).Value
If I change v to be an integer, the above is all illegal and "Invalid
use of null" will occur.
Second, note how I assigned a value of Null to v:
v = Null
not " IsNull (res) "
If you want to test if some variable is null, you use IsNull:
if IsNull(v) then
Msgbox "It's Null!"
else
Msgbox "It's " & v
end if
A stylistic point: try to avoid double negation. I like my last code
block better than:
if not IsNull(v) then
Msgbox "It's " & v
else
'Twist my brain: it's not not null.
Msgbox "It's Null!"
end if
-Tom.
in access 203 I am passsing some variables to a fuction and then
calculating on them and passing off this to another function.
my problem comes with the nulls
I am passing some values and strings to different functions
one problem I need to define a vaiable as int
dim res as integer
but when I do this
If Not IsNull(Me.Controls(str4).Value) Then
res = Me.Controls(str4).Value
Else
IsNull (res)
End If
if the control is null then res should be null
but res = 0
the only thing I can find is that res should be a variant
then I run into a problem that passing to the next function
If Not IsNull(ageck) And Not IsNull(wt) And Not IsNull(res) And Not
IsNull(pos) Then ' And Not IsNull(val2) Then
ckstuff2 ageck, wt, res, pos, val2
it looks as res and sure enough res (a variant) = 0
should I do something like this on the variable to define a null to a
99 so I can then look at it or what I am not sure what to do and don't
want to start replacing values.
iif(isnull(res),99,res)
.
- References:
- trying to use null but getting no where
- From: sparks
- Re: trying to use null but getting no where
- From: Tom van Stiphout
- trying to use null but getting no where
- Prev by Date: A2007 to A2003 question
- Next by Date: Access 2007 / ADO Provider for Internet Publishing
- Previous by thread: Re: trying to use null but getting no where
- Next by thread: Re: trying to use null but getting no where
- Index(es):
Relevant Pages
|