Query, empty or null field value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My query results do not return the records when there is an empty or null
value in any one field. Below is the my query. How would I modify this allow
the empty or null values. Thanks for yoru help.


strSQL = "SELECT * "
strSQL = strSQL & "FROM Posts INNER JOIN Signs ON Posts.PostID =
Signs.PostID "
strSQL = strSQL & "WHERE (((SIGNS.SignType) like """ & Me![cboSignType] &
""") "
strSQL = strSQL & " AND ((Signs.SignID) Like """ & Me![cboSignID] & """) "
strSQL = strSQL & " AND ((Signs.SignSize) Like """ & Me![cboSignSize] & """)"
strSQL = strSQL & " AND ((Signs.SignDescription) Like """ & Me![cboSignDesc]
& """))"
 
My query results do not return the records when there is an empty or null
value in any one field. Below is the my query. How would I modify this allow
the empty or null values. Thanks for yoru help.

strSQL = "SELECT * "
strSQL = strSQL & "FROM Posts INNER JOIN Signs ON Posts.PostID =
Signs.PostID "
strSQL = strSQL & "WHERE (((SIGNS.SignType) like """ & Me![cboSignType] &
""") "
strSQL = strSQL & " AND ((Signs.SignID) Like """ & Me![cboSignID] & """) "
strSQL = strSQL & " AND ((Signs.SignSize) Like """ & Me![cboSignSize] & """)"
strSQL = strSQL & " AND ((Signs.SignDescription) Like """ & Me![cboSignDesc]
& """))"

On each line you will have to add " OR (Signs.FieldName is Null)"
 
Perfect! Thanks for such a percise answer.

Jason Lepack said:
My query results do not return the records when there is an empty or null
value in any one field. Below is the my query. How would I modify this allow
the empty or null values. Thanks for yoru help.

strSQL = "SELECT * "
strSQL = strSQL & "FROM Posts INNER JOIN Signs ON Posts.PostID =
Signs.PostID "
strSQL = strSQL & "WHERE (((SIGNS.SignType) like """ & Me![cboSignType] &
""") "
strSQL = strSQL & " AND ((Signs.SignID) Like """ & Me![cboSignID] & """) "
strSQL = strSQL & " AND ((Signs.SignSize) Like """ & Me![cboSignSize] & """)"
strSQL = strSQL & " AND ((Signs.SignDescription) Like """ & Me![cboSignDesc]
& """))"

On each line you will have to add " OR (Signs.FieldName is Null)"
 
Incidentally, there's no point using LIKE, since you're not using wildcard
characters.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


finster26 said:
Perfect! Thanks for such a percise answer.

Jason Lepack said:
My query results do not return the records when there is an empty or
null
value in any one field. Below is the my query. How would I modify this
allow
the empty or null values. Thanks for yoru help.

strSQL = "SELECT * "
strSQL = strSQL & "FROM Posts INNER JOIN Signs ON Posts.PostID =
Signs.PostID "
strSQL = strSQL & "WHERE (((SIGNS.SignType) like """ & Me![cboSignType]
&
""") "
strSQL = strSQL & " AND ((Signs.SignID) Like """ & Me![cboSignID] &
""") "
strSQL = strSQL & " AND ((Signs.SignSize) Like """ & Me![cboSignSize] &
""")"
strSQL = strSQL & " AND ((Signs.SignDescription) Like """ &
Me![cboSignDesc]
& """))"

On each line you will have to add " OR (Signs.FieldName is Null)"
 
Actually, the default values for each of the comboboxes are a wildcards.

Douglas J. Steele said:
Incidentally, there's no point using LIKE, since you're not using wildcard
characters.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


finster26 said:
Perfect! Thanks for such a percise answer.

Jason Lepack said:
On Mar 22, 3:48 pm, finster26 <[email protected]>
wrote:
My query results do not return the records when there is an empty or
null
value in any one field. Below is the my query. How would I modify this
allow
the empty or null values. Thanks for yoru help.

strSQL = "SELECT * "
strSQL = strSQL & "FROM Posts INNER JOIN Signs ON Posts.PostID =
Signs.PostID "
strSQL = strSQL & "WHERE (((SIGNS.SignType) like """ & Me![cboSignType]
&
""") "
strSQL = strSQL & " AND ((Signs.SignID) Like """ & Me![cboSignID] &
""") "
strSQL = strSQL & " AND ((Signs.SignSize) Like """ & Me![cboSignSize] &
""")"
strSQL = strSQL & " AND ((Signs.SignDescription) Like """ &
Me![cboSignDesc]
& """))"

On each line you will have to add " OR (Signs.FieldName is Null)"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top