Hi everyone
So i have a list box that's row source is bound to a query (qryCompanyAndAssoc) that filters company information. There's two columns in this list box that display dates. Right now I'm trying to implement a date range filter, where the user selects a from and to date via two text boxes and the listbox would display the results. This is what I have so far:
AAEndDate = Association Agreement End Date
txtFrom = Date From
txtTo = Date To
The text boxes are set to Short Date format and when I select a date range then click search I'm given an error saying "Error: 2491 The action or method is invalid because the form or report isn't bound to a table or query" and DoCmd.ApplyFilter task is highlighted yellow.
If anyone has some suggestions or advice on how to solve this, a rookie like me, I would really appreciate it!
So i have a list box that's row source is bound to a query (qryCompanyAndAssoc) that filters company information. There's two columns in this list box that display dates. Right now I'm trying to implement a date range filter, where the user selects a from and to date via two text boxes and the listbox would display the results. This is what I have so far:
Code:
Private Sub Command81_Click()
'Search button
Call Search
End Sub
Sub Search()
Dim srchCriteria, task As String
Me.Refresh
If IsNull(Me.txtFrom) Or IsNull(Me.txtTo) Then
MsgBox "Please enter the date range", vbInformation, "Date Range Required"
Me.txtFrom.SetFocus
Else
srchCriteria = "([AAEndDate] >= #" & Me.txtFrom & "# And [AAEndDate] <= #" & Me.txtTo & "#)"
task = " SELECT * FROM qryCompanyANDAssoc WHERE (" & srchCriteria & ") order by [AAEndDate]"
DoCmd.ApplyFilter task
End If
End Sub
AAEndDate = Association Agreement End Date
txtFrom = Date From
txtTo = Date To
The text boxes are set to Short Date format and when I select a date range then click search I'm given an error saying "Error: 2491 The action or method is invalid because the form or report isn't bound to a table or query" and DoCmd.ApplyFilter task is highlighted yellow.
If anyone has some suggestions or advice on how to solve this, a rookie like me, I would really appreciate it!
Last edited by a moderator: