Hi, I have a query that populates a list box:
I'm trying to populate a text box with the value from the second column of the listSitesEdit listbox (which is [tblSite-type].[Site ID]. For some reason, It populates it with the first column value. Here's the code I have for trying to retrieve the value:
Not sure what I'm doing wrong
Code:
strSQL = "SELECT [tblSite-Type].[User Entered], [tblSite-Type].[Site ID], [tblSite-Type].[Superfund Site] "
strSQL = strSQL & "FROM [tblSite-Type] "
strSQL = strSQL & "ORDER BY [tblSite-Type].[Site ID], [tblSite-Type].[Superfund Site];"
Me.listSitesEdit.ColumnCount = 3
Me.listSitesEdit.ColumnHeads = True
Me.listSitesEdit.RowSourceType = "table/query"
Me.listSitesEdit.RowSource = strSQL
I'm trying to populate a text box with the value from the second column of the listSitesEdit listbox (which is [tblSite-type].[Site ID]. For some reason, It populates it with the first column value. Here's the code I have for trying to retrieve the value:
Code:
If Me.listSitesEdit.ListCount > 0 Then
For i = 0 To Me.listSitesEdit.ListCount - 1
If i = Me.listSitesEdit.Selected(i) Then
Me.txtSiteID.Value = Me.listSitesEdit.Column(i, 2)
End If
Next i
End If
Not sure what I'm doing wrong