Command Button to Find and Filter Records

L

LDMueller

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
 
M

Marshall Barton

LDMueller said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top