I tried to use a form as a query. Using date as the criteria. You can re-create this problem using northwind.mdb by creating two forms. I am using MS Access 97 SR-2<br><br><br>Problem :<br><br>Using date, it produces wrong data, or only some of the records.<br><br>To reproduce the error, I will use the Northwind database as example. We will create 2 forms; frmProb to act as filter and frmResult to see the result of the filter action. frmResult is bound to EMPLOYEES table.<br> <br><br>Reproduce the error : <br><br>1. create an unbound form named frmProb<br> create 2 textbox <br> name them fromdate and todate<br> Format : medium date<br> <br> create a command button<br> name : cmdFind<br> caption : Find<br> Event Procedure : On Click <br><br> Private Sub cmdFind_Click()<br> Dim strWhere As String<br> On Error GoTo Err_cmdFind_Click<br> strWhere = ("[HireDate] Between #" & Me!fromdate & "# AND #" & Me!todate & "#"
<br> DoCmd.OpenForm "frmResult", WhereCondition:=strWhere<br> <br> Exit_cmdFind_Click:<br> Exit Sub<br><br> Err_cmdFind_Click:<br> MsgBox Err.Description<br> Resume Exit_cmdFind_Click<br> <br> End Sub<br><br><br>2. create a form called frmResult<br> Record Source = Employees<br> <br> From Field List, <br> add employee ID, firstname and lastname, and hiredate to the detail<br><br>3. Close both forms.<br><br>4. Run frmProb, enter 1 March 1992 in fromdate. Enter 1 December 1992 in todate. <br>5. Click Find. The result is not correct.<br><br> <br>There is also wrong output when:<br>1) Values entered in both fromdate and todate are between 1-4 of any month of same year<br> Example : Fromdate = 1 March 1992 and Todate = 4 September 1992<br> the correct result should be 3 records, but the result here is 1 record.<br> Employees table show that there are 3 people hired from April to August.<br><br>I think there would be incorrect output by other combination as well.<br><br>There is correct output when<br>1) Value entered in todate is 5 and above, any month, same year<br>2) value entered in todate has different year from fromdate<br><br><br>Please help.....<br><br><br><br><br><br><br><br>