how to use the listbox value to update textbox
List box column numbering starts from zero, so the first column value is accessible as Me.listbox.Column(0)
. Access throws an error ("object required") when you append .Value
after the column.
Also you shouldn't need variables to store the column values before you assign them to the text boxes. You can assign the column values to the text boxes directly.
Private Sub listbox_AfterUpdate()
Me.[textbox1] = Me.listbox.Column(0)
Me.[textbox2] = Me.listbox.Column(1)
End Sub
user1921704
Updated on June 04, 2022Comments
-
user1921704 almost 2 years
I have an Access form with a list-box consisting of two columns and its MultiSelect property is set to None. I need to update 2 text-box using this list-box where if the user select an item from it the value of its first column is used to update one text-box and the value of the second column is used to update another text-box , something like :
Private Sub listbox_AfterUpdate() Dim colval1 As String Dim colval2 As String colval1 = Me.listbox.column(1).Value colval2 = Me.listbox.column(2).Value Me.[textbox1] = colval1 Me.[textbox2] = colval2 End Sub
I just don't know how to get the value of this list-box.