|
-
Feb 13th, 2005, 09:54 AM
#1
Re: check for duplicate items in combobox
 Originally Posted by kulrom
but why ... i've used DISTINCT many times before and i never noted any issue about that ... then i'm wondering why you recommend not using of DISTINCT?

DISTINCT and GROUP BY have a place in SQL - that's for sure.
But I've seen too many people develop a poor join - resulting in "phantom" duplicate rows and then using DISTINCT to get rid of them.
In the past 3 years we have developed nearly 1000 STORED PROCEDURES and I cannot remember the time we used SELECT DISTINCT.
Prior to MS SQL SERVER 2000, SELECT DISTINCT would build the resultset and then apply the DISTINCT upon it - GROUP BY was better. Now they are the same.
And as you can see from the reply - DISTINCT isn't going to work in this case either.
As for the DUPLICATE issue in the COMBO box - search around the FORUM, I've seen API tricks on COMBOBOXES that get rid of duplicates...
-
Feb 13th, 2005, 10:16 AM
#2
Thread Starter
Lively Member
Re: check for duplicate items in combobox
 Originally Posted by szlamany
As for the DUPLICATE issue in the COMBO box - search around the FORUM, I've seen API tricks on COMBOBOXES that get rid of duplicates...
I searched the forums, but i can't find it. what keyword should i use?
-
Feb 13th, 2005, 10:38 AM
#3
Re: check for duplicate items in combobox
 Originally Posted by digita
I searched the forums, but i can't find it. what keyword should i use?
It was tough to find - but here's a link:
Find a string in a combobox with API
-
Feb 13th, 2005, 12:25 PM
#4
Thread Starter
Lively Member
Re: check for duplicate items in combobox
what does it do, because i don't inderstand it, and how do i use it?
VB Code:
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) _
As Long
Private Const CB_ERR = (-1)
Private Const CB_FINDSTRING = &H14C
Private Const CB_FINDSTRINGEXACT = &H158
Private Function FindItemByString(cmb As ComboBox, ByVal SearchFor As String, Optional FindExact As Boolean = False) As Integer
FindItemByString = CInt(SendMessage(cmb.hwnd, IIf(FindExact, CB_FINDSTRINGEXACT, CB_FINDSTRING), _
CB_ERR, ByVal SearchFor))
End Function
-
Feb 13th, 2005, 01:08 PM
#5
Re: check for duplicate items in combobox
Hey, that looks very simlar to my code I posted a long time ago. 
What it does is use the sendmessage api to find in the passed combo box (depending on the exact or
like parameter being passed) a item with the same (exact or partial matching) combo item text. Then if it
finds it it will return the index integer of the found item.
VB Code:
'Usage for exact match:
Private Sub Command1_Click()
Combo1.ListIndex = FindItemByString(Combo1, Combo1.Text, True)
End Sub
If its not found then the function returns a -1 which will not give the combo an error but rather a no
selection depending on the Style of the combo box.
HTH
Last edited by RobDog888; Feb 13th, 2005 at 01:12 PM.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|