Problem solved. Thanks again for your patience and support. Your first code recommendation was correct all along. I had commented out a bit of the SQL statement which I now realise you can't do within the SQL. I removed that bit and it now all works.
Working code:
Code: Select all
WHERE (1 = 1)
" . $filter. " "
." ORDER BY
tblValues.SaleDate DESC ";