How to automate searching a field?

J

janet

On a form, what is easiest way to automate searching a
database field for an existing Last_Name?

Also, when I manually do Edit, Find, "Last_Name" field,
many first names show on form, but they are not in
alphabetical order, making the list difficult to use. How
to fix this?
 
A

Amir

this might help you since it works for me; Assuming that
Record Source table is Employees as is form too.
make a unbound combo box call it Find on form footer of
Employees then assign Row Source to something like this;
SELECT [Employees].LastName FROM [Employees] ORDER BY
[Employees].LastName;
and then on After Update insert this code;
On Error GoTo Err_After_Update
Dim vName As String
vName = Find
If Not vName = Empty Then
LastName.SetFocus
DoCmd.FindRecord vName, acEntire, False, , False, , True
Find.Value = Null
End If
Err_After_Update:
Exit Sub
That should be it. You can modify it to display lastname
& firstname very easily. And once you click on combo it
will display names and as you type it will narrow it
down, then just hit enter and it will bring you to that
person. Let us know how that works
 

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