combo box only loads one record into form

B

Bob Quintal

=?Utf-8?B?VGhlVmVoaWNsZUZpbmRlcg==?=
Hi,
I've created a combo box in a contact form to search for contacts
by first name. When it finds the name i want, all i do is select
by clicking from the dropdown menu, and it loads all fields from
the contact table into the form for that particular contact ready
for editing. It has an autopredict facility and works fine when
there is only one entry for a particular first name. I'm having
problems when is more than one record with a particular first
name, for example i have 3 keiths in the contact table and it will
only load the same one up despite me clicking on the others. There
is only one "Leo" for example and it has no problem loading up his
data. The code is as follows:

Private Sub Combo184_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[FirstName] = '" & Me![Combo184] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

Any help will be much appreciated.
Thanks,
Paul
Well, if you look at the code, it should be evident that findFirst
will find the first Keith each time you run it If you want to find
the second Keith you will need to change the findfirst to findNext.

Or you could do a findfirst on the firstname & lastname
rs.FindFirst "[FirstName] = '" & Me![Combo184] & "' AND " _
"[lastname] = """ & me![combo184].column(2) & """"
 
G

Guest

Hi,
I've created a combo box in a contact form to search for contacts by first
name. When it finds the name i want, all i do is select by clicking from the
dropdown menu, and it loads all fields from the contact table into the form
for that particular contact ready for editing. It has an autopredict facility
and works fine when there is only one entry for a particular first name.
I'm having problems when is more than one record with a particular first
name, for example i have 3 keiths in the contact table and it will only load
the same one up despite me clicking on the others. There is only one "Leo"
for example and it has no problem loading up his data.
The code is as follows:

Private Sub Combo184_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[FirstName] = '" & Me![Combo184] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

Any help will be much appreciated.
Thanks,
Paul
 
R

Rick Brandt

TheVehicleFinder said:
Hi,
I've created a combo box in a contact form to search for contacts by
first name. When it finds the name i want, all i do is select by
clicking from the dropdown menu, and it loads all fields from the
contact table into the form for that particular contact ready for
editing. It has an autopredict facility and works fine when there is
only one entry for a particular first name.
I'm having problems when is more than one record with a particular
first name, for example i have 3 keiths in the contact table and it
will only load the same one up despite me clicking on the others.
There is only one "Leo" for example and it has no problem loading up
his data.
The code is as follows:

Private Sub Combo184_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[FirstName] = '" & Me![Combo184] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

Any help will be much appreciated.
Thanks,
Paul

Even if the column you display in the drop down has duplicates the *bound*
column must be unique or you will have that problem.
 
B

Bob Quintal

=?Utf-8?B?VGhlVmVoaWNsZUZpbmRlcg==?=
Thanks for helping Bob.
The code you supplied is giving a "syntax error"?
Any suggestions?
Thanks again,
Paul
make sure it's all on one line, and make sure that the column(n)
reference poinst to the correct column in your combobox.
 
G

Guest

Thanks for helping Bob.
The code you supplied is giving a "syntax error"?
Any suggestions?
Thanks again,
Paul
 

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