Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Duplicate values in combo box 1

Status
Not open for further replies.

lppa

Technical User
Apr 5, 2004
26
US
In "Customers Info" Form I have unbound combo box used for Company/Last Name Search. In case of two or more same last names it returns only first (used combo box wizard with FindFirst method). How can I solve this problem, so it will return right record selected from combo box.

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

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

…and another question. Is it possible to open dropdown part of combo box as soon as you begin typing first letter, without clicking on arrow at the right.

Thank you.
 
You'll have to add more criteria to your find command.
try this:

Set rs = Me.Recordset.Clone
rs.Find "[CompanyLastName] = '" & Me.Combo49.column(0) & "' AND [CompanyName] = '" & Me.Combo49.column(1) & "'"

Of course you'll have to modify this code depending on the columns in your combobox.
To make the combo box open up, use this event on the key_press event:

Private Sub Combo49_KeyPress()
combo49.dropdown
End Sub

Good luck!

- RoppeTech
 
Thanks.

It worked perfectly. The only question I have is how to close dropdown part of combo box after record selected and set focus to another field.

Thanks again.

 
It should do it automatically when you select a value, but try this:

Private Sub Combo49_AfterUpdate()
combo49.requery
End Sub

or this:

Private Sub Combo49_AfterUpdate()
combo49.value = combo49.value
End Sub

- RoppeTech
 
Thanks. Everything works just fine. Appreciate your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top