Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Visual Basic 2005 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 31st, 2007, 09:04 PM
Registered User
 
Join Date: Jan 2007
Location: , , USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Changing combobox based on selection

I have two comboboxes.  One has items I input because there are only 4 choices to choose from.  Combobox 2 depends on what is selected on combobox one, but I don't know how to filter out combobox 2 based on what is selected on combobox 1.

Here is what I have:
Food_ComponentsCombobox has the items Milk, Meat, Fruits/Veg., and Grains/Breads

Food_Items_as_PurchasedCombobox is linked to a database that contains the columns Food Components and Food Items as Purchased plus some other stuff.

If I choose Milk in Food ComponentsCombobx, it should populate the Food_Items_as_PurchasedCombobox with only those food items that are milk.

I feel like I am going in the right direction, but I can't figure out the code that specifies I just want the Food Items the user selects.

This is my code and I advice that it is not working:

Private Sub Food_ComponentsComboBox_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Food_ComponentsComboBox.Click
        If Food_ComponentsComboBox.SelectedIndex = 1 Then
            Food_Item_as_PurchasedComboBox.Items.Clear()
            With Me.Food_Item_as_PurchasedComboBox
                .Items.Clear()

                .DataBindings.Add("Milk", Me.USDABindingSource, "Food Components", True)

                .DataSource = Me.USDABindingSource
                .DisplayMember = "Food Item as Purchased"
                .ValueMember = "Food Components"
            End With

        End If



When I run this I get a message "Cannot bind the property "Milk" on the target control" and it points to Food Components on the .Databindings.Add line.  I know I'm doing this wrong, but I don't know how to make this work.  Again, I need for the user to choose from 4 items on combobox 1.  Depending on the item chosen, combobox2 should populate itself with only the items related to the item chosen.  Can anyone help?  I'd really appreciate it.  Thanks!



http://www.galleons.org
__________________
http://www.galleons.com
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
selection based on conditions rajesh_css XSLT 3 October 2nd, 2008 09:06 PM
Fill DataGrid based on the selection in combobox drani C# 12 October 11th, 2007 06:41 PM
How to catch mouse selection on a combobox? jeffcflam Pro VB 6 0 May 24th, 2006 08:22 AM
ComboBox Selection Question vtonny1 Access 2 February 11th, 2006 01:14 PM
USER SELECTION FROM A COMBOBOX AxeSess Access VBA 3 February 15th, 2004 06:48 AM



All times are GMT -4. The time now is 05:40 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.