Wrox Programmer Forums
|
Pro VB Databases Advanced-level VB coding questions specific to using VB with databases. Beginning-level questions or issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 20th, 2006, 02:12 AM
Authorized User
 
Join Date: Jan 2006
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default Combobox Select/Insert Code

Hi all,

I have a combobox on my form. The combo is currently populated by values from a table in a DB. I have two questions:-
1- Suppose I need to select more than 2 items in the dropdown, how can I ascertain the selected items?

2 - I want my users to check in the combobox dropdown if what they are looking for is already available in the DB if NOT available, then I want to allow them to type/key in the missing item directly in the combobox is this possible?

If the answer is yes, please let me have a sample code of how I can code that.

Thanks

 
Old June 20th, 2006, 01:32 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

1. In a loop, run through each item and test whether its .Selected property is True. (There are samples of this in Help.)

2. Are you using VB 6, the VBA that is contained in Access, or . . . ?
    If you are not using the VBA behind Access, what is your data kept in?
 
Old June 21st, 2006, 02:35 AM
Authorized User
 
Join Date: Jan 2006
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Am using VB6 (forms & coding) and the database is stored in MsAccess 2003.

 
Old June 26th, 2006, 01:17 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

The Access controls are really helpful here. But you're using VB, so that's no help.

I just now made a simple form with a combo on it, and it allowed me to type randomly into it.
So then, on Lost Focus, Change, or maybe Validate, I suspect that you can search to see if the data typed in matches anything existing, and take appropriate action if not. (Add it to the database then requery, or whatever.) I'm afraid I'd need to do some experimentation to be more explicit.

Sure seems like a behavior that Microsoft could have anticipated a little better...
 
Old June 28th, 2006, 09:09 AM
Authorized User
 
Join Date: Jan 2006
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Brian,

Any idea how that can be coded?

Will really appreciate your help.

Thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I select an ITEM from a combobox? Ron Howerton VB.NET 2002/2003 Basics 18 October 2nd, 2015 09:18 PM
Help : combobox in xsl to select value by default priyatowin XSLT 8 July 3rd, 2008 09:05 AM
insert into....select problem timbal25 SQL Server 2005 1 October 24th, 2007 08:28 PM
Populate ListView From ComboBox Select eusanpe C# 4 August 20th, 2007 06:49 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.