Loading ADO Combo Box

What code is required to load an ADO combo box.  For example, with a regular combo box, this works:
 adoPrimaryRS.MoveFirst
 Do While adoPrimaryRS.EOF = False
  Combo1.AddItem adoPrimaryRS!ReportName
  adoPrimaryRS.MoveNext
 Loop
But this code cannot be used if the combo box is an ADO one.

bhatchelAsked:
Who is Participating?
 
Éric MoreauConnect With a Mentor Senior .Net ConsultantCommented:
When populating with the AddItem method, it doesn't matter if you use ADO compliant control or not.

If not bind, stick with the regular combo. You will be more confortable since you already know it!
0
 
Éric MoreauSenior .Net ConsultantCommented:
This control can only work in bound mode. You bind it at run-time this way:

Private Sub Form_Load()
    DataEnvironment1.rsCommand1.Open
    With DataCombo1
        Set .RowSource = DataEnvironment1.rsCommand1
        .ListField = "LastName"
    End With
End Sub

You can also bind it at design-time using the RowSource, RowMember and ListField property.

I just like to mention that «regular combo box» can be used if you would like to populate it with the AddItem method.
0
 
bhatchelAuthor Commented:
Thanks,
I was able to populate a regular combo box as you suggested, but was trying to be consistent with using ADO controls.
0
 
Éric MoreauSenior .Net ConsultantCommented:
Is it working?
0
 
bhatchelAuthor Commented:
I thought I responded before.  Your answer was exactly what I needed.  It's too bad Microsoft doesn't provide such complete examples.
0
All Courses

From novice to tech pro — start learning today.