devxlogo

Check Inequality of Database Field Values

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
See also  How to Create and Deploy QR Codes Online: A Comprehensive Guide
devxblackblue

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.

About Our Journalist