Hello, all!
In short what I am trying to achieve is to filter a bound form's shown records using the DoCmd.ApplyFilter method. This is form is bound to a table that houses information on preventative maintenance actions performed on machinery. The form itself is just a review form so the records can be checked to see if they were done and when.
I have 3 controls in the form I am trying to use as filters:
MachineComboBox
StartDateTextBox
EndDateTextBox
If I try a single filter (filtering by machine number) using the following code it works fine:
Code:
DoCmd.ApplyFilter , "[Machine]='" & Me.MachineComboBox & "'"
However, when I try to filter by machine number as well as by date range (the values between StartDateTextBox and EndDateTextBox) I get a syntax error:
Code:
DoCmd.ApplyFilter , "[Machine]='" & Me.MachineComboBox & "'"
DoCmd.ApplyFilter , "[PerformedOn] >='" & Me.StartDateTextBox & "'" and <='" & Me.EndDateTextBox & "'"
So my questions are, is trying to perform two filters in this way the wrong way to go about it, and in the second line of above code where am I going wrong. Admittedly (and obviously), I am horrible at using single and double quotes properly.
Thank you!
Edit: The textboxes are formatted as Short Date and the table column is formatted as Date/Time.