I Need a Help.
Im trying to filter my form by placing two Unbound boxes ( DateFrom and DateTo) I applied following VBA codes on a Button (CmdSearch) but it did not work. it show a Yellow Highlight on my last line (DoCmd.AppllyFilter task )
Im trying to filter my form by placing two Unbound boxes ( DateFrom and DateTo) I applied following VBA codes on a Button (CmdSearch) but it did not work. it show a Yellow Highlight on my last line (DoCmd.AppllyFilter task )
Code:
Private Sub CmdSearch_Click()
Call search
End Sub
Sub search()
Dim StrCriteria, task As String
Me.Refresh
If IsNull(Me.DateFrom) Or IsNull(Me.DateTo) Then
MsgBox "please enter the date range", vbInformation, " Date Range Required"
Me.DateFrom.SetFocus
Else
StrCriteria = "([Date_Due] >= #" & Me.DateFrom & "# And [Date_Due] <=#" & Me.DateTo & "#)"
task = "Select *from Forecast Where (" & StrCriteria & ") order by [Date_Due]"
DoCmd.ApplyFilter task
End If
End Sub