Put WHERE criteria in click event i/o in the report's record source
Posted on 2013-12-21
I have rptDepartures with WHERE criteria saved in the report record source like so:
SELECT tblDepartures.*, tblEndUser.[End User], tblDepartures.Compliance_GOPS_YN, Projects.[Project Name], Projects.ContractAward
FROM (tblDepartures LEFT JOIN Projects ON tblDepartures.ProjectID = Projects.ID)
LEFT JOIN tblEndUser ON Projects.EndUserID = tblEndUser.EndUserID
WHERE (((tblEndUser.[End User]) Like [forms]![frmDepartures_filter].[txtClient] & "*" Or (tblEndUser.[End User]) Is Null) AND ((tblDepartures.EntryDate)>=[forms]![frmDepartures_filter]![txtDateFrom] And (tblDepartures.EntryDate)<[forms]![frmDepartures_filter]![txtDateTo]+1 And (tblDepartures.EntryDate) Is Not Null))
ORDER BY tblEndUser.[End User];
I know experts like to put the where conditions under the button's click event i/o in the report criteria. So, now I want to move this criteria away from the record source of the report and move the WHERE condition to a button's macro event on the filter form (frmDepartures_filter).
I have played around with this for too long. I cant do it. Maybe putting such criteria in the macro's where condition is not a good idea and should instead be put in the click event of the button on frmDepartures_filter.
any help is appreciated.