I want to Remove Duplicate Item From the Combo Box.
How to Remove Duplicate Item?
Printable View
I want to Remove Duplicate Item From the Combo Box.
How to Remove Duplicate Item?
Use the RemoveItem method
Combo1.RemoveItem <Index number of item to be removed>
Do you want to stop from being added in the fisrt place or do you just want to remove all duplicates?Quote:
Originally posted by vijayarajah
I want to Remove Duplicate Item From the Combo Box.
How to Remove Duplicate Item?
Here is something to get you started.
VB Code:
Option Explicit Public Declare Function SendMessageStr Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, _ ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long Private Const CB_FINDSTRINGEXACT = &H158 Private Const CB_FINDSTRING = &H14C Public Function SearchCBO(ByRef cboCtl As ComboBox, ByVal sSearchCriteria As String, Optional ByVal bLIKE As Boolean) As Long '<RR 08/08/2003 - VB/OUTLOOK GURU> On Error GoTo No_Bugs If bLIKE = False Then 'EXACT MATCH SearchCBO = SendMessageStr(cboCtl.hwnd, CB_FINDSTRINGEXACT, 0&, ByVal sSearchCriteria) Else 'LIKE MATCH SearchCBO = SendMessageStr(cboCtl.hwnd, CB_FINDSTRING, 0&, ByVal sSearchCriteria) End If Exit Function No_Bugs: MsgBox Err.Number & " - " & Err.Description, vbOKOnly + vbInformation End Function Private Sub Command1_Click() If SearchCBO(Combo1, Combo1.Text, False) > -1 Then 'Exists already Else 'Not found in combo End If End Sub
Since I saw that you had an earlier thread about connecting VB app to remote ACCESS DB...
That makes me think I should ask you where the duplicates are coming from? Are you executing a QUERY that is giving you duplicates?