Forum Moderators: open
I am using Dreamweaver, and in the advanced recordset dialog box, I have defined four variables, the last variable being the date. Example: I would like a person to be able to search by "Town" (var1) and by "Date"(var4) to return a certain set of records.
The following code sorta works, but not quite way I want:
SELECT *
FROM tbl_final_publicRecordwLust
WHERE Town LIKE 'var1%' AND Address LIKE '%var2%' AND SiteName LIKE '%var3%' AND (InvestigationStartDate >= #var4# OR InvestigationStartDate IS NULL)
ORDER BY SiteName, Address, Town
The problem is if a person enters a date, the database correctly returns the records with the date AND all the records without a date - I don't want the non-dated records. I tried to write an IF statement, but it keeps bombing.
Any suggestions wuld be very appreciated!
SELECT *
FROM tbl_final_publicRecordwLust
WHERE Town LIKE 'var1%' AND Address LIKE '%var2%' AND SiteName LIKE '%var3%' AND InvestigationStartDate >= #var4# AND InvestigationStartDate IS NOT NULL
ORDER BY SiteName, Address, Town
If I modify per your code, the recordset will not return any records because of the "AND". (I'm assuming you delieberately left out the Parentheses from my code.) From the logic of it, eg "...AND InvestigationStartDate >= #var4# AND InvestigationStartDate IS NULL", the recordset is being asked to return var4 (the date) and the null records. It refuses to give me anything.
I put the parens back in:
SELECT *
FROM tbl_final_publicRecordwLust
WHERE Town LIKE 'var1%' AND Address LIKE '%var2%' AND SiteName LIKE '%var3%' AND (InvestigationStartDate >= #var4# AND InvestigationStartDate IS NULL)
ORDER BY SiteName, Address, Town
...and the result is still the same: no records.
arrgghh.