Fred,
You say "...still not working as I intened..." perhaps I missed it but what
results are you expecting?
After reading your code, not sure why you felt the need for txtSearchString?
(Watch out for word wrap.)
'****Start of UNTESTED Code****
Private Sub txtFirstName_Change()
On Error Resume Next 'Cause I'm too lazy to include real error handling
(that be Gina not you)
Dim strSQL As String
strSQL = "SELECT DISTINCTROW tblPeople.LastName, tblPeople.FirstName,
tblPeople.Address, tblPeople.MiddleName, tblPeople.FaxNumber,
tblPeople.AlternatePhone, tblPeople.DateClosed, tblPeople.FollowupDate FROM
tblPeople"
strSQL = strSQL & "WHERE (((tblPeople.FirstName) Like [Type in Any Part of
First Name or Enter for All] & "*")) OR (((tblPeople.DateClosed) Is Null))"
strSQL = strSQL & "ORDER BY tblPeople.FaxNumber DESC;"
Me!lstResults.RowSource = strSQL
Me!lstResults.Requery
Me!txtFirstName.SetFocus
End Sub
'****End of UNTESTED Code****
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" - Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Fred,
Slight change, see if the below works...
"WHERE ((tblPeople.FirstName) Like " & txtSearchString & "*") OR
((tblPeople.DateClosed Is Null))"
If that doesn't work then try it with the OR part and see if that works.
--
Gina Whipp
2010 Microsoft MVP (Access)
"I feel I have been denied critical, need to know, information!" - Tremors
II
http://www.regina-whipp.com/index_files/TipList.htm
Nothing is ever = Null.
But you can use
IsNull([FieldName])
or
[FieldName] Is Null
Also, it's not clear from your question as to whether or not you wish
to 'AND' the second condition or 'OR' it.
Try:
strSQL = strSQL & "WHERE ((tblPeople.FirstName) Like '" &
txtSearchString & "*') And tblPeople.DateClosed Is Null"
Change the And to OR if that is what you need.
Thanks for the suggestions. I've tried both of these formats.
Here's a copy and paste of the code I just added.
strSQL = strSQL & "WHERE ((tblPeople.FirstName) Like '" &
txtSearchString & "*') And tblPeople.DateClosed Is Null"
This produces no results. I tested the null statement with some other
criteria like = 1/2/2010 which has valid data in the table but still
was unable to return any results.
I appreciate the suggestions.
Still not working as intended.
Perhaps it would help if I shared the entire code?
Private Sub txtFirstName_Change()
Dim txtSearchString As Variant
Dim strSQL As String
txtSearchString = Me![txtFirstName].Text
strSQL = "SELECT DISTINCTROW tblPeople.LastName, tblPeople.FirstName,
tblPeople.Address, tblPeople.MiddleName, tblPeople.FaxNumber,
tblPeople.AlternatePhone, tblPeople.DateClosed,
tblPeople.FollowupDate FROM tblPeople "
strSQL = strSQL & "WHERE ((tblPeople.FirstName) Like " &
txtSearchString & "*') OR ((tblPeople.DateClosed Is Null))"
strSQL = strSQL & "ORDER BY tblPeople.FaxNumber DESC"
Me!lstResults.RowSource = strSQL
Me!lstResults.Requery
Me!txtFirstName.SetFocus
End Sub