Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Command Button to Find and Filter Records

Geek News

Command Button to Find and Filter Records
LDMueller 12/3/2008 12:23:00 PM
Hello,

I have Access 2003. I have a form with a Find Command button. When the
user clicks on the Find button I need it to prompt for the file number.
Then, when the enter a number like 5666533c it should filter for all records
like US5666533c (e.g. *5666533c). Below is my code. The results now finds
the exact number, but it's not filtered and I can scroll to other numbers.

Dim stDocName As String
Dim stLinkCriteria As String
Dim strFindID As String

strFindID = (InputBox("File Number?"))

If strFindID <> vbNullString Then
With Me.RecordsetClone
.FindFirst "[PatPubForNo] = """ & strFindID & """"

If .NoMatch Then
GoTo Found_cmdFindRecord_Click
Else
Me.Bookmark = .Bookmark
End If
End With
Else
MsgBox "Please enter a valid Patent, Publication, or Foreign No!"
End If

Any assistance is greatly appreciated.

Thanks,

LDMueller
Re: Command Button to Find and Filter Records
Marshall Barton <marshbarton[ at ]wowway.com> 12/3/2008 2:34:10 PM
LDMueller wrote:
[Quoted Text]
>I have Access 2003. I have a form with a Find Command button. When the
>user clicks on the Find button I need it to prompt for the file number.
>Then, when the enter a number like 5666533c it should filter for all records
>like US5666533c (e.g. *5666533c). Below is my code. The results now finds
>the exact number, but it's not filtered and I can scroll to other numbers.
>

Try using the Filter property instead:

Dim strFindID As String

strFindID = (InputBox("File Number?"))
If strFindID <> vbNullString Then
Me.Filter = "PatPubForNo Like ""*" & strFindID & """"
Me.FilterOn = True
Else
Msgbox ...
End If
--
Marsh
MVP [MS Access]

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net