Run time error ’94’ Invalid use of Null (1 Viewer)

rotorque

Registered User.
Local time
Today, 21:34
Joined
Dec 17, 2008
Messages
53
I have managed to write some vb to write data from one table to another. However, it seems to stop with a message (Run time error ’94’ Invalid use of Null).

This specifically occurs at the point

strVariable= ![Field]

Is there away I can put a statement in to avoid the nulls. If I use an if statement in the form…

If Field=null then…. It doesn’t seem to work and carries over the value anyway.

Any suggestions please.
 

rainman89

I cant find the any key..
Local time
Today, 17:34
Joined
Feb 12, 2007
Messages
3,016
how about
Code:
if isnull(field) then
dont do anything 
else
[FONT=Arial][SIZE=3]strVariable= ![Field]
end if
[/SIZE][/FONT]
 

rotorque

Registered User.
Local time
Today, 21:34
Joined
Dec 17, 2008
Messages
53
how about
Code:
if isnull(field) then
dont do anything 
else
[FONT=Arial][SIZE=3]strVariable= ![Field][/SIZE][/FONT]
[SIZE=3][FONT=Arial]end if[/FONT][/SIZE]

Ok Thanks. I'll give this a go.
 

rotorque

Registered User.
Local time
Today, 21:34
Joined
Dec 17, 2008
Messages
53
Copied in your result and I got the same result. The strVariable= ![Field] was highlighted in yellow and the value is null.
 

joh024

TJ
Local time
Today, 15:34
Joined
Jun 17, 2009
Messages
28
Copied in your result and I got the same result. The strVariable= ![Field] was highlighted in yellow and the value is null.

It might not understand where ![Field] is pointing to. add the object in front of the ! and it will probably work. Is this reading from a form or something? If so then just change it to me.Field.value, then test for null before proceeding.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 21:34
Joined
Sep 12, 2006
Messages
15,614
try

strVariable= nz([Field] ,vbnullstring)

why the ! ?
do you have a field called [field] ?

its not advised to use reserved words
 

rotorque

Registered User.
Local time
Today, 21:34
Joined
Dec 17, 2008
Messages
53
Thanks for the above. I'll try this tomorrow.
 

Users who are viewing this thread

Top Bottom