devxlogo

Check Inequality of Database Field Values

Conventional wisdom suggests this code works fine when checking a field in a database-or any Variant, for that matter-for inequality to some other value:

 If ![Name] <> "abc" Then	Debug.Print "<>"Else	Debug.Print "="End If

In reality, however, this isn’t always the case. For example, if the field you’re checking is of value Null, then the test also returns Null, invoking the Else clause. A quick, though perhaps obscure solution, is to check for equality instead:

 If ![Name] = "abc" Then	Debug.Print "="Else	Debug.Print "<>"End If

Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.

See also  How Engineering Leaders Spot Weak Proposals

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.