I am confused.....
You have a form with two unbound controls "StartDate" (shouldn't use spaces) and "EndDate".
You have a button that then opens a query????? Why isn't the query the record source for the form?
I would do this:
The form record source should be the query. Add the fields you want to view in the form detail section.
The button and two unbound controls "StartDate" and "EndDate" should be in the form header.
If the button name is "cmdSetFilter", the code behind the button should be something like:
Code:
Private Sub cmdSetFilter_Click()
Me.Filter="[ClassDate] Between #" & Format(nz([Forms]![Search Form]![Start Date],"01/01/2010"),"mm/dd/yyyy") & "# And #" & Format(nz([Forms]![Search Form]![EndDate],Date()),"mm/dd/yyyy") & "#"
Me.FilterOn
End Sub
And a 2nd button (cmdClearFilter) to remove the filter:
Code:
Private Sub cmdClearFilter()
Me.Filter = ""
Me.FilterOn = False
End Sub
-------------------------------
I build my filter "on-the-fly". Here is an example by Allen Browne:
How to build a criteria string form the non-blank search boxes
http://www.allenbrowne.com/ser-62code.html
Using this method, the unbound search controls can be left blank. You can have both controls blank, the "StartDate" blank, the "EndDate" blank or enter both "StartDate" and "EndDate" values.