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

SQL source for a ListBox?

Status
Not open for further replies.

solo7

Technical User
Mar 14, 2001
243
NO
I have my SQL string and I'm trying to assign it to a listbox to display what I want. My SQL string picks up user selected variables and I want it to pass the results to a list box, refreshing each time the user selection changes with an 'onclick' event
I have tried the ListRowSource property but to no avail.

solo7 [thumbsup2]
 
ok I'm still stuck on this on but I think I'm close :-
I have assigned a recordset to hold the SQL results and using DEBUG I know this works. I just need to get this recordset into my listbox. I have beeing adapting the code below but I get a 'Type mismatch' error

Code:
IntN=0
While Not recordset.EOF
StrTemp=recordset("Fld_Room")

list02.add StrTemp,IntN

recordset.MoveNext
IntN=IntN+1
Wend

Can anyone tell me if I'm close here or am I completley on the wrong tack?

solo7 [thumbsup2]
 
Hello solo7,

Not sure if it is a vbs question. But, your syntax suggests you should use .additem method instead of .add.

regards - tsuji
 
Thanks tsuji,
to know someone is reading this helps!
OK I'm not giving this one up ...

How about this. I have managed to populate a list box on the form already with a stored query (Qry1) and it works fine as this is the list the user clicks to get the variable that I want to pass to the next list box. How about if I can bind my listbox to a stored query BUT manipulate the query via script? So List00 is always bound to QryRooms, but QryRooms changes with each selection the user makes. Can I SAVE an SQL statement as a named query? - overiding any message which may occur to stop me saving a query with the same name?

solo7 [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top