I’m trying to display data in multiple columns in a listbox on a form and am running into trouble with an “Object Required” error message. My listbox is set to Value List, Column Count of 2, and I’ve assigned appropriate widths to the columns (through the property sheet). I think I’m not correctly referencing the columns. The code I’m using is shown below.
I’ve checked that the recordset is querying correctly and the “With lstParks” code works correctly if I remove the reference to specific columns (which unfortunately I do need).
Any ideas?
Thanks.
Code:
Set rs = db.OpenRecordset("Select * from [tbl_parks] " & _
"where tbl_records_objectives.UNIQUE_SECTION_LINK = " & ConservationAreaID & "")
'Display NAME in first column of list box
With lstParks.Column(0)
Do Until rs.EOF
.AddItem rs("NAME")
rs.MoveNext
Loop
End With
'Display LOCATION in second column of listbox
With lstParks.Column(1)
Do Until rs.EOF
.AddItem rs("LOCATION")
rs.MoveNext
Loop
End With