Question : Having 'No Records Found' display in listbox

I am using a listbox to display the results of a search.

I am trying to get the listbox to display 'No Records Found' when, the search returns 0 in recordset

I used a MsgBox but would like to see if the text can be displayed in the listbox.

my code block is below...... not working! not dispalying anything.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
Set rs = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
    If rs.RecordCount > 0 Then
        lstSearchResults.ColumnCount = rs.Fields.Count
        lstSearchResults.ColumnHeads = True
        lstSearchResults.BoundColumn = 0        
        Me.lstSearchResults.RowSource = strSQL
    
        txtRecCount = lstSearchResults.ListCount - 1
        SetColWidths
        
 Else
        'MsgBox "no records found"
        lstSearchResults.ColumnHeads = False
        'lstSearchResults.BoundColumn = 0
        lstSearchResults.ColumnCount = 1
        lstSearchResults.Rowsource = "No Records Found"
        
        SetColWidths
    End If
    
    Set rs = Nothing
Open in New Window Select All

Answer : Having 'No Records Found' display in listbox

This works here..

lstsearchresults.ColumnHeads = False
lstsearchresults.BoundColumn = 1
lstsearchresults.ColumnCount = 1
lstsearchresults.RowSourceType = "Value List"
lstsearchresults.RowSource = "No Records Found"    

Random Solutions  
 
programming4us programming4us