Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Jul 2008
    Suffolk, United Kingdom
    Thanked 0 Times in 0 Posts
    Hi Everyone,

    I need a little help...

    I have a visual basic 2010 windows application, with a user control in a form, the user control display's data from a database table call sm_tblProduct. One of the columns in the table is CategoryID this column is an interger datatype. I have another table called sm_tblProductCategory with two columns ProductCategoryID and Description

    On the user control I want the combo box CategoryIDComboBox to lookup its value from sm_tblProductCategory, I want it to display in the UI the data from the description column (which is text)

    I can get the above to work using the code below, however when I click on the save button, nothing happens, basically because I am trying the save the category description (text) into an interger column

    If I change the line 'CategoryIDComboBox.DisplayMember = "Description"' to 'CategoryIDComboBox.DisplayMember = "ProductCategoryID"' the update/save will work but the user is stuck with seeing the product category id only which is not very useable when there are more categories then you can remember the id's of.

    Private Sub ucProducts_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim dt As DataTable
    Dim ta As New Store_ManagerDataSetTableAdapters.sm_tblProductCat egoryTableAdapter

    ta.Fill(Store_ManagerDataSet.sm_tblProductCategory )

    dt = Store_ManagerDataSet.Tables("sm_tblProductCategory ")

    CategoryIDComboBox.DisplayMember = "Description" 'CategoryIDComboBox.DisplayMember = "ProductCategoryID"
    CategoryIDComboBox.ValueMember = "ProductCategoryID"
    CategoryIDComboBox.DataSource = dt
    End Sub

    Many thanks in advance for your time and help
    Gerbil (AKA Kevin)

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Silicon Valley, USA
    Thanked 93 Times in 89 Posts
    I'm not familiar with .Net comboboxes, but can you create a hidden column and populate that with your key value? Here's a Word doc showing how you could implement that in a VBA UserForm. That's ancient technology, but might give you some ideas.

    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts