Solved combobox binding to ms access

Posted on 2005-04-23
Last Modified: 2006-11-18

Is there a simple way to bind a combobox to a ms access table?

And if you have two comboboxes on a form, how do you bind the second combobox to the same table displaying data using the dis played data from the first combobox as the criteria?

Thanks in advance
Question by:abennett10
    LVL 28

    Expert Comment

    create a dataset from th table and then

    cboA.DataSource = ds1.Tables(0).DefaultView
    cboA.ValueMember = ds1.Tables(0).Columns("id").ToString
    cboA.DisplayMember = ds1.Tables(0).Columns("name").ToString

    Author Comment


    But how does the second combobox retrive it's data to Display from the criteria set by cboA?
    LVL 28

    Accepted Solution

    when you create dataset you are using SQL for example
    sSQL = "select FieldName from Table1"
    now you create ds1

    after that you select the Value in the combobox and use it for you new SQL

    sSQL = "select Whatever from Table1 where FIeldName = '" & cboA.Text & "'"
    watch quotes in case it is a string and do it without quotes if it is a number

    now create a second dataset ds2 and bind it to cboB

    cboB.DataSource = ds2.Tables(0).DefaultView
    cboV.ValueMember = ds2.Tables(0).Columns("id").ToString ' or what ever column you need
    cboB.DisplayMember = ds2.Tables(0).Columns("name").ToString

    Author Comment

    Thank you! That will do it!
    LVL 28

    Expert Comment

    Can I ask you , why grade B? Is something wrong?

    Author Comment

    Well.....not to sound ungrateful, because I'm not trust me.....I just was hoping you would give me an example with more detail Emphasizing the syntax more....that's all

    But I really do appreciate the response and answer

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now