Turn a filter off

G

Guest

I have a form that has a button on it called Command184. When the user
clicks on this button , it prompts the person for a File ID. I want the
button to automatically turn off the filter when the File ID is found on the
form so that they can edit the data. Can this be done? I have added the code
below for you to review.



Private Sub Command184_Click()
Dim RetVal As String
RetVal = InputBox("Enter the File ID Number")
If RetVal <> "" Then
Me.Filter = "[File ID] = '" & RetVal & "'"
Me.FilterOn = True
End If
End Sub
 
G

Guest

Your post is a bit confusing. First, your code is explicity setting the
filter to the selected File ID. If you mean you want to turn it off if no
FileID is selectedL:

Private Sub Command184_Click()
Dim RetVal As String

RetVal = InputBox("Enter the File ID Number")
If RetVal <> "" Then
Me.Filter = "[File ID] = '" & RetVal & "'"
Me.FilterOn = True
Else
Me.FilterOn = False
End If
End Sub

Also, the Filter has no effect on whether records in the curren record
source (filtered or not) can be edited.
 

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

Top