FindFirst on list box

I am using the FindFirst  method and for each  record found,
I have a list that's contain a id, first name and last name.
on click on the list it take the same id in the edit box for id
 I take an action.
It's seem, When i have the same name it take the first name .
How can i solve this problem ?

Private Sub list0_Click()

Dim rst As Recordset
Set rst = Me.RecordsetClone


rst.FindFirst "[Name]='" & list0.Column(0) & "' And [LastName]='" & list0.Column(1)  & "'"
If rst.NoMatch Then
    MsgBox "There is No Name"
End If

 If Not rst.EOF Then
    Me.Bookmark = rst.Bookmark
 End If


End Sub

Open in new window

Brahim DjouadiAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gustav BrockCIOCommented:
FindFirst does what it says, finds the first entry that matches.

Include FirstName in the search to find individual names.
1
Brahim DjouadiAuthor Commented:
Thank you Gustav Brock
the field [Name] mean the first name
 how can i  solve my problem to take the next name
i'm new in acces
0
Gustav BrockCIOCommented:
Well, you can move to the next:

If Not rst.EOF Then
    rst.MoveNext
    If Not rst.EOF Then
        Me.Bookmark = rst.Bookmark
    End If
End If

Open in new window

1
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

Brahim DjouadiAuthor Commented:
the same problem
 MoveNext does nothing

if i have two same names

on click on the list the edit boxes that contain id,firstname and the lastname value it take the same value for the first id,firstname and the lastname

It's seem, When i have the same name and last name it take the first record .
0
Gustav BrockCIOCommented:
If you search for something (a combination of fields/values) that is unique, it will find that entry. Otherwise, it will find the first match.
That's by design.
0
Brahim DjouadiAuthor Commented:
are there any type to find a solution to do this
example
if i have 5 names like this:
========================
id   -    firstname   -  lastname
1          jhon               helen
2          adam             gebson
3          jhon               helen
4         admin            master
5         jhon                helen
========================

and i have edit box with query for search on event on change
when i search for that name jhon
it will show the three names
and on click on one of them  they take the same id
witch mean it only take the first

how can i make it when i click on any name give me it's  id
0
Gustav BrockCIOCommented:
Yes. Use the first field, ID, as the bound column of the listbox.
That will make ID the selected value, and that is unique.
1
Brahim DjouadiAuthor Commented:
how can i do that ?

because i think FindFirst accept only strings

i have attached my file can you do that

and thank you
example.mdb
0
Gustav BrockCIOCommented:
I couldn't get your upload to work. It seems hosed somehow.
So, I created a new. It works, though I'm not sure exactly how you intended, as that is not very clear.
example2.accdb
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Brahim DjouadiAuthor Commented:
Thank You Gustav Brock
you help me a lot with this example file

i will attach the correct file

for helping other user if any one need it or have the same problem
example2.accdb
0
Brahim DjouadiAuthor Commented:
All Done
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.