Problem with OR in SQL statement

jackieann

New member
Local time
Today, 07:16
Joined
Aug 24, 2015
Messages
3
I am trying to insert the following into a query on one line with "or" in between. The code works but when I run it, "Like '3' appears on one line and Is Null appears below it. Is there a way I can pass this to the query so it shows, Like '3' or Is Null on one line? Hope this makes sense. Thanks!

strCriteria5 = "SalesbyRSM3.Relay_Rep Like '3'" & " OR SalesbyRSM3.Relay_Rep Is Null "
 
I am trying to insert the following into a query on one line with "or" in between. The code works but when I run it, "Like '3' appears on one line and Is Null appears below it. Is there a way I can pass this to the query so it shows, Like '3' or Is Null on one line? Hope this makes sense. Thanks!

strCriteria5 = "SalesbyRSM3.Relay_Rep Like '3'" & " OR SalesbyRSM3.Relay_Rep Is Null "
What do you mean by "on one line"?
 
It shows like this.

Like '3'
Is Null

One beneath the other.

I want it to show as

Like '3' or Is Null (on one line in the Access query) with OR separating the two criteria's
 
When you use
...Like '3' --it is the same as = '3'

You would normally use like to find if a string is contained within a variable/field
eg

dim strx as string
strx= "abcdefghijkl"

If str x like "*xzy" then ' x ends with xyz


strCriteria5 = "SalesbyRSM3.Relay_Rep Like '3' OR SalesbyRSM3.Relay_Rep Is Null "
or
strCriteria5 = "SalesbyRSM3.Relay_Rep Like '3'" _
& " OR IsNull(SalesbyRSM3.Relay_Rep) "

IsNull() is a function in Access vba.
Is NULL is an operator in SQL
 

Users who are viewing this thread

Back
Top Bottom