I have a form with a combo box that gets populated on form load. I want the user to be able to select a value in the combo box, click on a command button with sql that should populate the rowsource of the list box with the results. Not getting any results in the list box. Code:
Private Sub Form_Load()
Me.cboTrackName.RowSourceType = "Table/Query"
Me.cboTrackName.RowSource = "SELECT DISTINCT dbo_wagers.track" & _
" FROM dbo_wagers WHERE dbo_wagers.track Is Not Null ORDER BY dbo_wagers.track;"
Me.cboTrackName = Me.cboTrackName.ItemData(0)
Private Sub cmdFilteredResults_Click()
Dim strSQL As String
strSQL = "select dbo_wagers.wager from dbo_wagers where dbo_wagers.track = ' " & Me.cboTrackName.Value & "'"
MsgBox "Current track selected is " & Me.cboTrackName.Value & ""
MsgBox "Query is " & strSQL & ""
Me.lstResultsByTrack.RowSourceType = "Table/Query"
Me.lstResultsByTrack.RowSource = strSQL
Any suggestions appreciated.