Tony,
I'm not going to check your SQL, but I'll suggest something else.
Like something simple and easy to do.
On the form, create a button as in Part 2 of your post.
Put these in the on click event button.
'--------------------textbox filter
code--------------------------------------
-
If Not IsNull(Me.[txtstartdate] And Me.[txtenddate]) Then
If Not IsNull(Me.[txtname]) Then
Me.YourListBoxName.RowSource = "QryResult1"
Me.YourListBoxName.Requery
End If
End If
If Not IsNull(Me.[txtstartdate] And Me.[txtenddate]) Then
If IsNull(Me.[txtname]) Then
Me.YourListBoxName.RowSource = "QryResult2"
Me.YourListBoxName.Requery
End If
End If
If IsNull(Me.[txtstartdate] And Me.[txtenddate]) Then
If Not IsNull(Me.[txtname]) Then
Me.YourListBoxName.RowSource = "QryResult3"
Me.YourListBoxName.Requery
End If
End If
If IsNull(Me.[txtstartdate] And Me.[txtenddate]) Then
If IsNull(Me.[txtname]) Then
Me.YourListBoxName.RowSource = "QryResult4"
Me.YourListBoxName.Requery
End If
End If
'----------------------end of
code--------------------------------------------
---
Next, create 4 queries and name them as below or your choice.
Name of Query ---- "QryResult1"
SELECT tblInstitution1.ID, tbldocument.txtRefNbr,
tbldocument.txtExpirydate,
tblInstitution1.txtInstitution, tblInstitution1.txtlastname,
[txtFirstname]
& " " & [txtlastname] AS Contact, forms!frmsearch3!txtstartdate AS Expr1,
forms!frmsearch3!txtenddate AS Expr2
FROM tbldocument LEFT JOIN tblInstitution1 ON tbldocument.txtRefNbr =
tblInstitution1.txtRefNbr
WHERE (((tbldocument.txtExpirydate) Between [Forms]![frmsearch3]!
[txtstartdate] And [forms]![frmsearch3]![txtenddate]) AND
((tblInstitution1.txtlastname) Like [Forms]![frmsearch3]![txtname] &
"*"));
Name of Query ---- "QryResult2"
SELECT tblInstitution1.ID, tbldocument.txtRefNbr,
tbldocument.txtExpirydate,
tblInstitution1.txtInstitution, tblInstitution1.txtlastname,
[txtFirstname]
& " " & [txtlastname] AS Contact, forms!frmsearch3!txtstartdate AS Expr1,
forms!frmsearch3!txtenddate AS Expr2
FROM tbldocument LEFT JOIN tblInstitution1 ON tbldocument.txtRefNbr =
tblInstitution1.txtRefNbr
WHERE (((tbldocument.txtExpirydate) Between [Forms]![frmsearch3]!
[txtstartdate] And [forms]![frmsearch3]![txtenddate]));
Name of Query ---- "QryResult3"
SELECT tblInstitution1.ID, tbldocument.txtRefNbr,
tbldocument.txtExpirydate,
tblInstitution1.txtInstitution, tblInstitution1.txtlastname,
[txtFirstname]
& " " & [txtlastname] AS Contact, forms!frmsearch3!txtstartdate AS Expr1,
forms!frmsearch3!txtenddate AS Expr2
FROM tbldocument LEFT JOIN tblInstitution1 ON tbldocument.txtRefNbr =
tblInstitution1.txtRefNbr
WHERE
(((tblInstitution1.txtlastname) Like [Forms]![frmsearch3]![txtname] &
"*"));
Name of Query ---- "QryResult4"
SELECT tblInstitution1.ID, tbldocument.txtRefNbr,
tbldocument.txtExpirydate,
tblInstitution1.txtInstitution, tblInstitution1.txtlastname,
[txtFirstname]
& " " & [txtlastname] AS Contact, forms!frmsearch3!txtstartdate AS Expr1,
forms!frmsearch3!txtenddate AS Expr2
FROM tbldocument LEFT JOIN tblInstitution1 ON tbldocument.txtRefNbr =
tblInstitution1.txtRefNbr;
Be aware that I'll be using "Between" for the Where clause of your date
filter.
Never lump multiple filter conditions into one SQL. Break them into
managable
queries so that you can avoid errors.
And refer to Marshall question on,
(tbldocument.txtExpirydate)<=[forms]![frmsearch3]![txtstartdate]
And
(tbldocument.txtExpirydate)>=[forms]![frmsearch3]![txtenddate])
And maybe I'm wrong, but your monster query seems to nullify all records.
And also check your date format. E.g. 01/05/06 = 1-May-06 or
01/05/06 = 5-Jan-06.
Tony said:
My list box is still not being populated if I put the dates in.
This is my SQL for the list box row source