Runtime error 2491 in a Navigation Form

annarocha

New member
Local time
Today, 07:15
Joined
May 5, 2016
Messages
6
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
 
i think it has to do with your DoCmd.ApplyFilter.
is the form bound?
 
It is. But once you put it into the Navigation form it seems to lost something.
 
how about not using filter, but instead change the rowsource of your form.
also you have error in "task" there:

task = "select * from " & Me.8CONST & " where (" & strcriteria & ") order by [EffectiveDate]"

me.recordsource = task
 
upload the db for us to see.
 
Ok. I did a small sample on my issue.
I was using a 5/1/16 to 5/31/16 for my sort dates. I should return 1 item.:banghead:.
I appreciate any help I can get!

Thank you!
Anna Rocha
 

Attachments

here is the fix, please review the code behind your search button click event.
 

Attachments

Users who are viewing this thread

Back
Top Bottom