Null Problem

mohammadagul

PrinceAtif
Local time
Today, 13:49
Joined
Mar 14, 2004
Messages
298
Hello To All Sophisticated Programmer,

I have a simple problem. I am trying to Put Images in my forms. What i have done is :

1. Created a Text Field name imagePath.
2. Add an image Frame in the Form.

When the user double clikc the image fram the file locator dialog box appears(as you have seen in windows). The user choose the path of the image and add it inthe text field. The problem comes when there is no picture inthe image frame. System keeps on giving an error message as such.

Run Time Error 94
Invalid use of null

i found one function on Allen Brown Website which is as follows

Null2Zero(), StrLen()
These two functions are very simple but useful, since Nulls propagate like rabbits in Access.
Use Null2Zero() to prevent runtime errors when assigning values to non-variants,
or to prevent calculations choking over Nulls.

Function Null2Zero (AValue)
' Purpose: Return the value 0 if AValue is Null.
If IsNull(AValue) Then
Null2Zero = 0
Else
Null2Zero = AValue
End If
End Function
Len() returns Null as the length of a Null variant, so StrLen() is a quick substitute.
Since any non-zero value = True, you can test for no entry (Null or zero length string)
with If Not StrLen([MyControl]) Then

Function StrLen (AVariant) As Integer
' Returns the length of a variant or string, returning zero a
Null or zero-length string.
If IsNull(AVariant) Then
StrLen = 0
Else
StrLen = Len(AVariant)
End If
End Function


I have tried using the above codes but allinvain. the error keeps on coming. Is there any other way of removing the error.

Suggestion and answeres will be highly appretiated

Muhammad Atif Gul
 
hello

Somone out there can help me. Please Tell me what to do about this Error

Please

Muhammad Atif Gul
 
Isnt there any one in the Forum who can help me with this null situation
 
Where are you calling the functions from?

If the field you are trying to pass has a null value then you won't be able to pass it.
 
mohammadagul,

In the past, I have used the MSAccess Application Public Method NZ().

The syntax of the function is: Nz(Value, [ValueIfNull]).


Kind regards,
 
thanks for reply,

first of all it is any image frame and i am trying to callthe function on the OnCurrent of the form.

I event tried to use the Nz but keeps on giving the error
 
Yes, and you will continue to get the error if you continue to pass a null value to a function.

If you are calling StrLen then the variant AVariant must have a value to receive otherwise it gets Null and this is an illegal receipt.

So, when calling it, try

MyValue = StrLen(Nz(value,vbNullString))

or some other value.
 

Users who are viewing this thread

Back
Top Bottom