Hi Guys,
Could somebody help with an issue I have regarding a date range search.
I have a form with two date picker field (Date From & Date To) which set the range to select from a query. Below is what I'm using to set the date range, the "To" date works but the "From" date also selects dates prior to the required date, does this make sense?
Private Sub btnSearchDateFrom_Click()
Call Search
End Sub
Sub Search()
Dim strCriteria, task As String
Me.Refresh
If IsNull(Me.txtSearchFrom) Or IsNull(Me.txtSearchTo) Then
MsgBox "Please Enter Date Range", vbInformation, "Date Range Is Required"
Me.txtSearchFrom.SetFocus
Else
strCriteria = "([DateofDelivery] >= #" & Me.txtSearchFrom & "# And [DateofDelivery] <= #" & Me.txtSearchTo & "#)"
task = "select * from qrysearchdaterange where (" & strCriteria & ") order by [dateofdelivery]"
DoCmd.ApplyFilter task
End If
End Sub
Any suggestions would be gratefully received.
Thanks
Could somebody help with an issue I have regarding a date range search.
I have a form with two date picker field (Date From & Date To) which set the range to select from a query. Below is what I'm using to set the date range, the "To" date works but the "From" date also selects dates prior to the required date, does this make sense?
Private Sub btnSearchDateFrom_Click()
Call Search
End Sub
Sub Search()
Dim strCriteria, task As String
Me.Refresh
If IsNull(Me.txtSearchFrom) Or IsNull(Me.txtSearchTo) Then
MsgBox "Please Enter Date Range", vbInformation, "Date Range Is Required"
Me.txtSearchFrom.SetFocus
Else
strCriteria = "([DateofDelivery] >= #" & Me.txtSearchFrom & "# And [DateofDelivery] <= #" & Me.txtSearchTo & "#)"
task = "select * from qrysearchdaterange where (" & strCriteria & ") order by [dateofdelivery]"
DoCmd.ApplyFilter task
End If
End Sub
Any suggestions would be gratefully received.
Thanks