combo box only loads one record into form

  • Thread starter Thread starter Bob Quintal
  • Start date Start date
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) & """"
 
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
 
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.
 
=?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.
 
Thanks for helping Bob.
The code you supplied is giving a "syntax error"?
Any suggestions?
Thanks again,
Paul
 
Back
Top