T
Tsuby
Hi,
I need help in filtering data on a form, because it is behaving in a strange
way and it really puzzles me.
The database was originally written for access 2000, but I've decided to
update to 2003 now.
Everything is working fine, up to the filter.
I have an unbound textbox (Filtro) on the form and I wish to filter all
records on the form according to the text I input. If there is no match,
then I want a message to be displayed and to stay on the original record.
This is my code:
---
Private Sub Filtro_AfterUpdate()
Dim rs As DAO.Recordset
Dim strWhere As String
strWhere = "[Title] Like " & Chr(34) & "*" & Me![Filtro] & "*" & Chr(34)
If Me.Dirty Then Me.Dirty = False
If Me.FilterOn Then Me.FilterOn = False
Set rs = Me.RecordsetClone
rs.Filter = strWhere
If rs.NoMatch Then
MsgBox "Not found"
Else
Me.Bookmark = rs.Bookmark
End If
Set rs = Nothing
End Sub
---
Of course... it does not work.
I had to change the (working) filter of access 2000 because it would lock up
the form if I launched the filter from the first record and there was no
match. I just can't make it work.
Can you help me find the mistake, please?
Thanks
Erika
I need help in filtering data on a form, because it is behaving in a strange
way and it really puzzles me.
The database was originally written for access 2000, but I've decided to
update to 2003 now.
Everything is working fine, up to the filter.
I have an unbound textbox (Filtro) on the form and I wish to filter all
records on the form according to the text I input. If there is no match,
then I want a message to be displayed and to stay on the original record.
This is my code:
---
Private Sub Filtro_AfterUpdate()
Dim rs As DAO.Recordset
Dim strWhere As String
strWhere = "[Title] Like " & Chr(34) & "*" & Me![Filtro] & "*" & Chr(34)
If Me.Dirty Then Me.Dirty = False
If Me.FilterOn Then Me.FilterOn = False
Set rs = Me.RecordsetClone
rs.Filter = strWhere
If rs.NoMatch Then
MsgBox "Not found"
Else
Me.Bookmark = rs.Bookmark
End If
Set rs = Nothing
End Sub
---
Of course... it does not work.
I had to change the (working) filter of access 2000 because it would lock up
the form if I launched the filter from the first record and there was no
match. I just can't make it work.
Can you help me find the mistake, please?
Thanks
Erika