Answered by:
how to prevent duplicates in a combobox coming from database in vb6

Question
-
hi !
i am adding records from my access database and put it in a combobox . it was successful but is there a way that can prevent duplcates to add from the combobox?
please help
this is my code
Dim cnview As New ADODB.connection
Dim rsview As New ADODB.recordset
Call connection(cnview, App.Path & "\dbEmploymentSystem.mdb", "engman")
Call recordset(rsview, cnview, "SELECT * FROM tblReferral ORDER BY Company ASC")
While rsview.EOF = False
cmbSort2.AddItem rsview!Company
rsview.MoveNext
Wend
rsview.Close
Set rsview = Nothinghope you can help me
- Moved by Franklin ChenMicrosoft employee Tuesday, October 1, 2013 1:49 AM Off-Topic
Monday, September 30, 2013 1:43 AM
Answers
-
Hi,
this is a VB.Net-only forum. Have a look here if you still want to produce VB6 code:
Visual Basic 6.0 Resource Center
Armin
- Proposed as answer by Cor Ligthert Monday, September 30, 2013 6:04 AM
- Unproposed as answer by Niel18 Monday, September 30, 2013 6:34 AM
- Proposed as answer by Cor Ligthert Monday, September 30, 2013 7:01 AM
- Marked as answer by Just Karl Wednesday, October 9, 2013 2:27 PM
Monday, September 30, 2013 2:01 AM -
Shanks Zen <abbr class="affil" style="margin:0px 0.5em;padding:0px;border:0px;vertical-align:top;display:inline-block;color:#000000;"></abbr> <time style="margin:0px;padding:0px;border:0px;vertical-align:baseline;">Monday, March 11, 2013 10:20 AM</time>
This forum is for problems and discussions related to programming with VB inside Visual Studio for versions starting with the .Net version (2002). Before posting your question, check if your issue is related to the following categories. In order to get better response, take a look at How to Use this Forum.
Category
Appropriate forum
Other versions of Visual Basic
GUI related
ASP.Net forums (ASP and VB for MVC)
Forms Design and .Net Controls
SQL transact
3rd party products
.NET Framework Class Libraries
Windows
WCF, System.Net namespace and remoting technology
Windows Communication Foundation, Serialization, and Networking
If you have any suggestion to this table, please jump into this threadfor discussion.
You could share this announcement via this URL: http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/threads?announcementId=b5956386-b706-4180-b003-6e778f582d89#b5956386-b706-4180-b003-6e778f582d89.
Success
CorMonday, September 30, 2013 7:04 AM
All replies
-
Hi,
this is a VB.Net-only forum. Have a look here if you still want to produce VB6 code:
Visual Basic 6.0 Resource Center
Armin
- Proposed as answer by Cor Ligthert Monday, September 30, 2013 6:04 AM
- Unproposed as answer by Niel18 Monday, September 30, 2013 6:34 AM
- Proposed as answer by Cor Ligthert Monday, September 30, 2013 7:01 AM
- Marked as answer by Just Karl Wednesday, October 9, 2013 2:27 PM
Monday, September 30, 2013 2:01 AM -
Shanks Zen <abbr class="affil" style="margin:0px 0.5em;padding:0px;border:0px;vertical-align:top;display:inline-block;color:#000000;"></abbr> <time style="margin:0px;padding:0px;border:0px;vertical-align:baseline;">Monday, March 11, 2013 10:20 AM</time>
This forum is for problems and discussions related to programming with VB inside Visual Studio for versions starting with the .Net version (2002). Before posting your question, check if your issue is related to the following categories. In order to get better response, take a look at How to Use this Forum.
Category
Appropriate forum
Other versions of Visual Basic
GUI related
ASP.Net forums (ASP and VB for MVC)
Forms Design and .Net Controls
SQL transact
3rd party products
.NET Framework Class Libraries
Windows
WCF, System.Net namespace and remoting technology
Windows Communication Foundation, Serialization, and Networking
If you have any suggestion to this table, please jump into this threadfor discussion.
You could share this announcement via this URL: http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/threads?announcementId=b5956386-b706-4180-b003-6e778f582d89#b5956386-b706-4180-b003-6e778f582d89.
Success
CorMonday, September 30, 2013 7:04 AM -
you can use "distinct" key word in the sql query so that you will not get duplicate result.
SELECT *, distinct "field name" FROM tblReferral ORDER BY Company ASC
the above "field name" you can you use for binding to combo box.
- Proposed as answer by MalleswaraRaoMareedu Monday, September 30, 2013 11:43 AM
Monday, September 30, 2013 7:12 AM -
hey i try ur given code but i encountered an error..
Syntax error (missing operator) in query operation 'distinct Company'.
Monday, September 30, 2013 7:30 AM -
You can try like this..
SELECT distinct Company, * FROM tblReferral ORDER BY Company ASC
- Proposed as answer by MalleswaraRaoMareedu Monday, September 30, 2013 11:42 AM
Monday, September 30, 2013 9:12 AM -
hey i try your given code but the code is not working .. please helpMonday, September 30, 2013 11:59 PM
-
Hi Niel,
Since VB6 product is not supported in this forum, you may go to these forums for support:
#Where to post your VB 6 questions
http://social.msdn.microsoft.com/Forums/en-US/6a0719fe-14af-47f7-9f51-a8ea2b9c8d6b/where-to-post-your-vb-6-questionsThank you for your understanding.
Best regards,
Franklin<THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
Thanks
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.Tuesday, October 1, 2013 1:48 AM