(Solved) – Populate 14 Different TextBoxes based on User Listbox Selection


I’m very new to VBA and i’m hoping someone can help me or at least point me in the right direction.
I’m trying to populate 14 different text boxes on a form every time a user selects a row in the Listbox on the same form. However, I get the below error message every time.

I did some research and I see that it may be because i have more than 10 columns and to use an array instead, but I’m not sure how to implement this. Here’s my code

Private Sub LoadData()
Dim strIndvdlID As String

With Me.lbAudit
    CurrentListIndex = .ListIndex

    Me.txtGUID.value = .Column(COL_GUID .ListIndex)
    strIndvdlID = .Column(COL_iNDVDLID, .ListIndex)
    Me.txtLocationID.value = .Column(COL_LocationID, .ListIndex)
    Me.txtName.value = .Column(COL_Name, .ListIndex)
    Me.txtDataLead.value = .Column(COL_DataLead, .ListIndex)
    Me.txtHML.value = .Column(COL_HML, .ListIndex)
    Me.txtDirector.value = .Column(COL_Director, .ListIndex)
    Me.txtManager.value = .Column(COL_Manager, .ListIndex)
    Me.txtLead.value = .Column(COL_Lead, .ListIndex)
    Me.txtType.value = .Column(COL_Type, .ListIndex)
    Me.txtPlannedStartDate.value = .Column(COL_PlannedStartDate, .ListIndex)
    Me.txtPlannedEndDate.value = .Column(COL_PlannedEndDate, .ListIndex)
    Me.txtActualStartDate.value = .Column(COL_ActualStartDate, .ListIndex)
    Me.txtActualEndDate.value = .Column(COL_ActualEndDate, .ListIndex)     
End With
End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *