I'm getting this error
**Run-time error 2491
The action or method is invalid because the form or report isn't bound to a table or query.
I'm using a search/filter in my form and it works fine. But once I added it to a Navigation form it is giving me the error.
This is the code I'm using.
Option Compare Database
Private Sub Searchbutton_Click()
'search button
Call Search
End Sub
Sub Search()
Dim strcriteria, task As String
Me.Refresh
If IsNull(Me.StartDate) Or IsNull(Me.EndDate) Then
MsgBox "Please enter the date range", vbInformation, "Date Range Required"
Me.StartDate.SetFocus
Else
strcriteria = "([EffectiveDate] >= #" & Me.StartDate & "# And [EffectiveDate] <= #" & Me.EndDate & "#)"
task = "select * from Me.8CONST where(" & strcriteria & ") order by [EffectiveDate]"
DoCmd.ApplyFilter task
End If
End Sub
********
If anyone can help!
Thank you!
Anna
**Run-time error 2491
The action or method is invalid because the form or report isn't bound to a table or query.
I'm using a search/filter in my form and it works fine. But once I added it to a Navigation form it is giving me the error.
This is the code I'm using.
Option Compare Database
Private Sub Searchbutton_Click()
'search button
Call Search
End Sub
Sub Search()
Dim strcriteria, task As String
Me.Refresh
If IsNull(Me.StartDate) Or IsNull(Me.EndDate) Then
MsgBox "Please enter the date range", vbInformation, "Date Range Required"
Me.StartDate.SetFocus
Else
strcriteria = "([EffectiveDate] >= #" & Me.StartDate & "# And [EffectiveDate] <= #" & Me.EndDate & "#)"
task = "select * from Me.8CONST where(" & strcriteria & ") order by [EffectiveDate]"
DoCmd.ApplyFilter task
End If
End Sub
********
If anyone can help!
Thank you!
Anna