Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listbox Source is Recordset 2

Status
Not open for further replies.

Kib

Programmer
May 17, 2001
58
US
How can I make a listbox's source be a recordset that is created in code?
Thanks
 
You could use the command:

strSQL = "Select......"
me.listboxname.rowsource = strSQL
 
This info has helped me as well. For some reason, however. If I use a variable to hold the SQL, it will not work. If I define the SQL directly in the second line, it works fine.
ie
strSQL = "Select......"
me.listboxname.rowsource = strSQL
Doesn't work

but
me.listboxname.rowsource = "Select......"
Does Work
 
Try

Dim strSQL as string
strSQL = "Select......"
me.listboxname.rowsource = strSQL
 
Alternatively you could use the NAME property of the (DAO) recordset. This technique is very useful because it allows you to use recordsets as recordsources for forms and reports as well!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top