Combo Box is only populating one field

Viewed 23

(Cross Posted from Reddit)

Hi there, I'm trying to populate a combo box with records from an ADODB recordset, and while I can see all of the records in my Locals Window, the combo box is only populating the first record found. I've used this code hundreds of times on other projects and haven't had this issue. Is there something I'm missing?

Private Sub UserForm_Initialize()
Stop
Dim TestObject As Object
Dim TestSource As String
Dim TestDBConn As ADODB.Connection
Dim TestRecordset As ADODB.Recordset
Dim TestRows As Variant

Set TestObject = ComboBox1

TestSource = "SELECT [tblAgents].[FirstName] & ' ' & " & _
    "[tblAgents].[LastName] AS AgentName FROM tblAgents;"

    Set TestDBConn = New ADODB.Connection
    Set TestRecordset = New ADODB.Recordset
    
    TestDBConn.ConnectionString = StrCallDB
    
    TestDBConn.Open
    
        With TestRecordset
            .ActiveConnection = TestDBConn
            .Source = TestSource
            .LockType = adLockOptimistic
            .CursorType = adOpenDynamic
            .Open
        End With
        
TestRows = TestRecordset.GetRows

With TestObject
    .Clear
    .List = TestRows
End With

    TestRecordset.Close
    TestDBConn.Close
    
    Set TestRecordset = Nothing
    Set TestDBConn = Nothing
End Sub
1 Answers

I did testobject.list = application.transpose(TestRecordset) and that seemed to have done the trick

Related