Results 1 to 2 of 2

Thread: Combo Box

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Location
    Chicago, IL
    Posts
    13

    Post

    I am new to VB database programming so this may be an easy question, but any help would be appreciated.

    The database I am using was orignally created in Access. In table A there is a combo box that gets is choices from table B. The combo box has a one-to-many relationship between table A and B. What I need to know is how on a VB form do I get my choices from table B and set the combo box to the choice that is selected in table A.

    Thanks in advance for any help you can provide.

  2. #2
    Addicted Member
    Join Date
    Oct 1999
    Posts
    253

    Post

    The general idea is that you need to bind the ComboBox to the appropriate field of table A and then write code that opens table B and fill the ComboBox.

    Fortunately, there are special ActiveX controls that will do the work for you. If you are using DAO, you can use the DBCombo control. If you are using ADO, it's the DataCombo control. Both of them come with VB.

    The DataCombo control has 4 important properties, except of the DataSource, DataMember and DataField. The 4 properties are: RowSource, RowMember, BoundColumn and ListField. RowSource and RowMember are very similar to DataSource and DataMember. BoundColumn needs to be set to the name of the key field of table B and ListField to the name of the field you want to display in the ComboBox.

    If you want more explanations, I think there's a VB sample of these controls that come with VB.


Posting Permissions

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



Click Here to Expand Forum to Full Width