Null value

Gunilla

Registered User.
Local time
Today, 10:40
Joined
Mar 2, 2010
Messages
32
Why cann't I get the code to understand that if the field is empty the value is "Null"? The format is number and the default value is null. The user have to enter a number. I want a messagebox message if the value is Null (or if you want the box is empty).

My code is
if me!codeId.value=Null then
msgbox("You have to enter a number")
me.codeId.setfocus
else
end if

Why doesn't it work?

I have tried
if me!codeId=Null
if me!codeId=0
if me!codeId=""

I think I have tried everything,but I don't get it to work.
Gunilla:eek:
 
Is the text box bound to a field in your database or is it unbound.

If the text box is unbound then you will have to first set focus to the text box and then check for the text property to get the value. Like:

me.codeId.setfocus
If me.codeId.text > 0 then
'more code to do something here

endif
 
You do not check, in VBA, with =Null, you use

If IsNull(me!codeId) Then

but then if you have an empty string ("") it can look like a null but isn't.

So this code will check for both:

If Len(me!codeId & "") <> 0 Then
 
Is the text box bound to a field in your database or is it unbound.

If the text box is unbound then you will have to first set focus to the text box and then check for the text property to get the value. Like:

Remember Mr. B that you don't want to use

.Text

as that requires the control to have focus and that is totally uneccessary.
 

Users who are viewing this thread

Back
Top Bottom