populate list box data using recordset

jamest85

Registered User.
Local time
Yesterday, 18:18
Joined
Jan 20, 2008
Messages
52
Hi:
I have a listbox, and a recordset (DAO.Recordset).
If I clike a button, and go through the code line by line, the listbox can show the result: when hit the line:
Set Me.listBoxResult.Recordset = rs

However, if I don't go through the code line by line, just click the button, it just won't show the result in the list box.

Can you help me on this?

Below is code:
==============
Dim rs As DAO.Recordset
Dim strSQL As String

strSQL = "SELECT [STORE], [STORE NAME],[STATE] FROM FIELD_HR_LISTT WHERE [STORE] = '0105 '"

Set rs = CurrentDb.OpenRecordset(strSQL)


If (rs.RecordCount <> 0) Then Set Me.listBoxResult.Recordset = rs
End IF

================
Thank you very much.

James
 
Why not just assign the SQL statement to the recordsource, or maybe it's rowsource, property of the control...
Code:
Me.lst.rowsource = _
  "SELECT STORE, [STORE NAME], [STATE] " & _
  "FROM FIELD_HR_LISTT " & _
  "WHERE [STORE] = '0105 '"
 
thanks

Why not just assign the SQL statement to the recordsource, or maybe it's rowsource, property of the control...
Code:
Me.lst.rowsource = _
  "SELECT STORE, [STORE NAME], [STATE] " & _
  "FROM FIELD_HR_LISTT " & _
  "WHERE [STORE] = '0105 '"

Thank you, it works great!
 

Users who are viewing this thread

Back
Top Bottom