radink wrote:
I would like to make a command button on a form that lets you enter a
users name, and then if finds and displays only the records from that
user in the same form. I've tried doing it via a filter, but I'm not
sure im doing it correctly.
One thing you have to be careful of is if you actually have the data that
you want to filter on in your form's Recordsource. Is the UserName field
being displayed with a ComboBox or is the table using a (ugh) Lookup field?
In those cases you might see one thing on your form, while the actual data
in the table is something else (like an ID number). The filter obviously
needs to filter on what is actually there, not necessarily what you see.
If what you are seeing is the actual data then a filter should work. You
can apply one with a command button with the following code...
Dim NameFilter as String
NameFilter = InputBox("Enter Name to Filter On")
If NameFilter <"" Then
Me.Filter = "NameField = '" & NameFilter & "'"
Me.FilterOn = True
End If
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com