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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL and Listboxes

Status
Not open for further replies.
Joined
May 7, 2004
Messages
17
Location
US
I think I am alittle over my head here. I would like to use a SQL command to fill a listbox from an access database.

I understand how to use the SELECT command but I dont know how to put that data into the listbox.

Thanks in advance for your help.
 
Use a loop to scroll thru each record and add it to your box.

Something like this:

Do While Not MyRecordset.EOF

** Add current record to box then move to next record **

MyRecordset.MoveNext
Loop
 
The bit you may be looking for is AddItem:

Code:
 Do While Not rs.EOF
 List1.AddItem rs.Fields("Name")
 rs.MoveNext
 Loop

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'If we're supposed to work in Hex, why have we only got A fingers?'
Essex Steam UK for steam enthusiasts
 
Or you might use the ! symbol:

while not rs.eof
list1.additem rs!Name
rs.movenext
wend
 
Hallo,

this is very simple (here is a sample):
Quiry = "SELECT * FROM XXTABLE"
rsIps.Open Quiry, CnIps, adOpenStatic, adLockReadOnly, adCmdUnknown

lstVrsta.Clear

Do While Not rsIps.EOF
DoEvents
LstVrsta.AddItem rsIps("DS02VRSTA") & Space(1) & rsIps("DS02NAZIV")
rsIps.MoveNext
Loop

lstVrsta.ListIndex = 0
lstVrsta.Refresh

If rsIps.State = adStateOpen Then rsIps.Close

Lp, DaT

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top