T
Tony Williams
I have built a search form that has three unbound controls. On is a text
control that the user can input the company name or contact and the other
two are date controls where the user can put in a date range. Here is the
sql
SELECT tblInstitution1.ID, tbldocument.txtRefNbr, tbldocument.txtExpirydate,
tblInstitution1.txtInstitution, [txtFirstname] & " " & [txtlastname] AS
Contact
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] &
"*")) OR (((tbldocument.txtExpirydate) Between
[forms]![frmsearch3]![txtstartdate] And [forms]![frmsearch3]![txtenddate])
AND ((tblInstitution1.txtInstitution) Like [Forms]![frmsearch3]![txtname] &
"*"));
However I want the user to the ability to search without putting in a date
range and changed the sql to this
SELECT tblInstitution1.ID, tbldocument.txtRefNbr, tbldocument.txtExpirydate,
tblInstitution1.txtInstitution, [txtFirstname] & " " & [txtlastname] AS
Contact
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] &
"*")) OR (((tbldocument.txtExpirydate) Between
[forms]![frmsearch3]![txtstartdate] And [forms]![frmsearch3]![txtenddate])
AND ((tblInstitution1.txtInstitution) Like [Forms]![frmsearch3]![txtname] &
"*")) OR (((tblInstitution1.txtInstitution) Like
[Forms]![frmsearch3]![txtname] & "*")) OR (((tblInstitution1.txtlastname)
Like [Forms]![frmsearch3]![txtname] & "*"));
But this doesn't work it wont show any records with just the name text field
showing. Anyone help?
Thanks
Tony
control that the user can input the company name or contact and the other
two are date controls where the user can put in a date range. Here is the
sql
SELECT tblInstitution1.ID, tbldocument.txtRefNbr, tbldocument.txtExpirydate,
tblInstitution1.txtInstitution, [txtFirstname] & " " & [txtlastname] AS
Contact
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] &
"*")) OR (((tbldocument.txtExpirydate) Between
[forms]![frmsearch3]![txtstartdate] And [forms]![frmsearch3]![txtenddate])
AND ((tblInstitution1.txtInstitution) Like [Forms]![frmsearch3]![txtname] &
"*"));
However I want the user to the ability to search without putting in a date
range and changed the sql to this
SELECT tblInstitution1.ID, tbldocument.txtRefNbr, tbldocument.txtExpirydate,
tblInstitution1.txtInstitution, [txtFirstname] & " " & [txtlastname] AS
Contact
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] &
"*")) OR (((tbldocument.txtExpirydate) Between
[forms]![frmsearch3]![txtstartdate] And [forms]![frmsearch3]![txtenddate])
AND ((tblInstitution1.txtInstitution) Like [Forms]![frmsearch3]![txtname] &
"*")) OR (((tblInstitution1.txtInstitution) Like
[Forms]![frmsearch3]![txtname] & "*")) OR (((tblInstitution1.txtlastname)
Like [Forms]![frmsearch3]![txtname] & "*"));
But this doesn't work it wont show any records with just the name text field
showing. Anyone help?
Thanks
Tony