Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Null values appearing as not null

Status
Not open for further replies.

Andy6666uk

Programmer
Jul 11, 2001
17
GB
hi there

I am pulling strings out of the database and then checking to see if they are null or not.

I have tried both of the if-then staements below but it still recognises the string as not null even if it is null.

if not IsNull(strThis) and strThis <> &quot;&quot; then
code
end if

if not IsNull(strThis) and len(strThis) > 0 then
code
end if

the strings are from text fields in an access db.

thanks for your help, Andy
 
Hi

You have put the value of your field into a viariable before the check. This will turn a null into an empty string.

You may also have just an empty string instead of null, especially if you have a default value on the access filed of &quot;&quot;.

Also you are checking to see if the string is Try using the IsEmpty() check, that'll catch them all.

Code:
If not IsEmpty(strThis) then
Derren
[Mediocre talent - spread really thin]
 
You may also want to run a trim and recheck if it passes Derren's solution. There are cases where access will have spaces in fields and I don't think IsEmpty will catch them, but to us humans they are still 'empty'.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top