VB 2008 customer form.  Update textbox field based on combobox selection

Posted on 2009-02-22
Last Modified: 2013-12-25
new to, creating a form where user can select customer from combobox and then the form will fill in the corresponding data for the textboxes on the form for the address fields.
The combobox is bound to a table with all the customers and their corresponding fields.
How do I populate the textboxes with the corresponding field data based on the selection of the combobox?
Question by:David Barman
    1 Comment
    LVL 8

    Accepted Solution

    The are many ways to achieve this.

    One simple way is to use the combobox SelectedIndexChanged event.

    After you have assigned a handler for the event either through the UI or via code:
            AddHandler ComboBox1.SelectedIndexChanged, AddressOf ComboBox1_SelectedIndexChanged

    Firstly set the combobox ValueMember property to a column that is the unique identifier of the customer. This will be used to filter your table through the use of a View, which will be created from your existing table.
        Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
            Dim view As New DataView(table)
            view.RowFilter = "ID = " + Me.ComboBox1.SelectedValue
            nameTextBox.Text = view(0)("Name").ToString()
        End Sub

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Introduction In a recent article ( for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
    Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    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

    10 Experts available now in Live!

    Get 1:1 Help Now