Results 1 to 7 of 7

Thread: Differentiate between items in DataCombo Box [VB6]

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2003
    Posts
    308

    Question Differentiate between items in DataCombo Box [VB6]

    This should be easy to explain but I assume the solution won't be so simple...
    Given a form [frmMain] which has a DataCombo Box [dcbCustomer] which is currently populated by a single RecordSet [oRecsC] which has the list of CUSTOMERS as shown below

    Code:
    Dim oRecsC As New ADODB.Recordset
    Set oRecsC = SearchC
    Set DcbCustomer.RowSource = oRecsC
    DcbCustomer.ListField = oRecsC(0).Name
    Thing is there is another RecordSet [oRecsG] that has a list of GROUPS that I also want to add to this DataCombo Box - thus this is my first question, how can I add more then one RecordSet to the DataCombo Box?

    Now comes the REAL hard/fun part - I need to find a way to differentiate between the two lists [a CUSTOMER or a GROUP] both visually [maybe make the GROUP entires BOLD or COLORED or ANYTHING...] and via CODE [if a CUSTOMER is selected do this, if a GROUP is selected do that].
    Is this possible? Is there a better way to do it? I have been trying to get this to work for a while now and have been completly unable.

    So, in the dcbCustomer if the user selects (Private Sub DcbC_Change() event) a CUSTOMER (which originated from the oRecsC list) then do X, if the user selects a GROUP (which originated from the oRecsG list) then do Y.
    At the same time if the GROUPS were BOLDED in the list or something so the user can see "this is a Customer and this is a Group" it would be amazing .. I need some way to visually make the difference also.
    Any help/hints would be much appreciated, thanks

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Differentiate between items in DataCombo Box [VB6]

    You can't bind a control to two different recordsets. One solution would be to use a regular combobox instead and loop through each of the recordset and manually add the items to the combo. However to distinguish the items you can't use a regular combo, so maybe you should consider using an image combo instead and add one image for each item belonging to the customer recordset and another image for the groups.

  3. #3
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Differentiate between items in DataCombo Box [VB6]

    If you can bind it to a recordset then create a query that selects what u need
    like

    SELECT customer, Group FROM TableCustomer,TableGroup WHERE TableCustomer.CustomerID = TableGroup.CustomerID

    this is assuming you have some way to "link" the customer to the group
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2003
    Posts
    308

    Re: Differentiate between items in DataCombo Box [VB6]

    [A51g]Static: I like that idea but how do I differentiate between them?
    (Groups and Customers)?

    Joacim Andersson: Is there really no other way? I use the DataComboBox for a lot of other things and changing it would probably cause some massive re-writes.

  5. #5
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Differentiate between items in DataCombo Box [VB6]

    Not sure what u mean? cant a data combo have 2 columns? (I thought it could but could be wrong)
    is the data something like this?
    Customer1 Group1
    Customer2 Group1
    Customer3 Group1
    Customer1 Group2
    Customer2 Group2
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  6. #6
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: Differentiate between items in DataCombo Box [VB6]

    Is it possible to use a 'join' type SQL statement and bind the combox box to it?

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2003
    Posts
    308

    Re: Differentiate between items in DataCombo Box [VB6]

    [A51g]Static: I think it can only have one column (it is a drop-down), so more like
    Customer1
    Customer2
    Group1
    Customer3
    Group2
    Group3
    ...etc...
    So when the user selects GROUP1 I need to know this is a GROUP and not a CUSTOMER (of course the names aren't going to be so obvious in real life)

    Pasvorto: Yes but that doesn't help me very much

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