Populating a DataCombo Box with ADO RecordSet 
Author Message
 Populating a DataCombo Box with ADO RecordSet

I'm trying to populate a data combo box with data from an ADO recordset.  I
just can't seem to get it right.  Any  references given use a text box with
the command buttons used to navigate.

I need to have the entire collection placed into a DataCombo Box.

I there any who has done this?

Much thanks....



Mon, 17 Dec 2001 03:00:00 GMT  
 Populating a DataCombo Box with ADO RecordSet
Here's what I've done.

(1) create a local ado record set

Public Sub LoadCountyLookupRS()

    Dim sSql As String

    sSql = ""
    sSql = sSql & "SELECT county_code, county_name, county_id "
    sSql = sSql & "FROM lkp_county ORDER BY county_code"

    'Open a Record record set using the SQL query
    'created above to contain the selected record's data.

    Set mCountyRS = Nothing

    Set mCountyRS = mdlUtils.OpenRS(sSql, _
                            adOpenStatic, _
                            adLockBatchOptimistic, _
                            mAdoCn, _
                            " County Lookup Recordset.")
End Sub

(2) load the combobox from the recordset.  My combobox is named
      cboCounty

Public Sub InitializeCountyLookup()

   Dim mLookupRS as ADODB.Recordset
   Dim iRecCount As Integer

   Set mLookupRS = frmMain.ctlLkpCounty.AttachCountyRS

   mLookupRS.MoveFirst

   For iRecCount = 1 To mLookupRS.RecordCount
        cboCounty.AddItem mLookupRS!county_code
        mLookupRS.MoveNext
   Next

   Set mLookupRS = Nothing

End Sub

Best of luck.

BBFrost


Quote:
>I'm trying to populate a data combo box with data from an ADO recordset.  I
>just can't seem to get it right.  Any  references given use a text box with
>the command buttons used to navigate.

>I need to have the entire collection placed into a DataCombo Box.

>I there any who has done this?

>Much thanks....



Mon, 17 Dec 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. DataCombo box using ADO recordset

2. Populate text box with info from datacombo

3. Populating datacombo from ADO control error while saving

4. Pl. Help, Populating datacombo from ADO

5. Navigating through Recordsets using DataCombo (ADO)

6. ADO Recordsets and DataCombos

7. ADO recordset position and datacombo ctrl.

8. Navigating through Recordsets using DataCombo (ADO)

9. ADO DataCombo Bind to a Recordset.

10. Populating a TDBGrid with an ADO Recordset

11. How to Populate an ADO RecordSet

12. Populating TreeView with flat ADO Recordset

 

 
Powered by phpBB® Forum Software