Difference between = "" and <> ""

edubbelaar

New member
Local time
Today, 23:32
Joined
Nov 24, 2004
Messages
6
Hello all,

I'm dealing with this strange issue for some time:

In my Access VBA code a want to check if a required text field is not empty. Therefore I used the follow code:

Code:
If ReqField = "" Then
   MsgBox ("Oops...")
Else
   MsgBox ("Okay, let's continue!")
End If
But this function is not working. When a change the code to:

Code:
If ReqField <> "" Then
   MsgBox ("Okay, let's continue!")
Else
   MsgBox ("Oops...")
End If
its working fine.

Could anyone tell me what the difference is between those functions?
And when (and how) do you use the terms ‘IsNull’ or ‘Null’

What's the difference between ‘Null’ and ‘""’ for a string?

Thanks in advice! :)
 
If you need to check for an empty field you should use null or isnull or not isnull etc (exact syntax depends on where you use it). Note that ReqField = null wont work null is not a value so you have to test for null eg if isnull(ReqField) then.....

An alternative approach is for example the following

text = ReqField

if text & "" = "" then .....

or if text & "" <>"" then...
 

Users who are viewing this thread

Back
Top Bottom