Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter not valid

Status
Not open for further replies.

jamjam007

Programmer
Jun 24, 2005
2
0
0
US
Hello!

I have this recordset rst. I am filtering it using a criteria. rst.filter = "Filterstring"

But when the filter doesnt work, i.e. no records filtered, it gives Rum-time error 3265 Item cannot be found in the collection corresponding to the required name or cardinal.

How can I test this and avoid.

Thanks
b
 
how about errorhandling?

Code:
Sub YourSubName()
On Error GoTo err

[green]'your code
' ....
' ....[/green]

ExitSub:
Exit Sub

err:
If err.Number = 3265 Then [green]'here the error 3265 is trapped[/green]
Resume Next               [green]'and here the error 3265 is ignored[/green]
Else:
MsgBox err.Number & " " & err.Description
Resume ExitSub
End If

End Sub

HTH,
fly

[blue]Typos, that don't affect the functionality of code, will not be corrected.[/blue]

Martin Serra Jr.
[blue]Shared Database_Systems and _Applications across all Business_Areas[/blue]
 
I know this works in VB, not sure about VBA. Right after the rst.filter statement, check to see if the recordset is empty. Example:

If Not(rst.BOF And rst.EOF) Then

...

Else

...

End If

The first part of the If statement will execute if the recordset is NOT empty. The Else will execute if the recordset is empty. Hope this helps.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top