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

finding records from access database based on a item selected frmo a l

Status
Not open for further replies.

johnnyv

Programmer
Jul 13, 2001
216
CA
I am trying to find records from a access database based on a selection from a listbox. I am having trouble with the sql statement. can I use an ado control to do this

this is the sql statement I am using ??

adorecordset3.Open "Select [album name],[songname1] From [Query1] Where [album name] ='"listbox1'", adoconnection

thanks for your help
 
Whaddya mean Barq's has bite? Johnny?
Oh hey man!

k, couple o questions for you:
1. Are the users only selecting one item from the list box?

ok, really only one question. I'm pretty sure I can help you out on this, but if you have icq, message me at 54706142
and we can talk more then. Otherwise, just post a response here and we'll keep the conversation going ala Tek Tips

Jackamundo
 
yes that is right the users will select one item from the list box. The list box contains album names. I want to take the selected album name find the matching record in the database so I can pull out the song names for that album and then place the
names of the songs in a list box
 
Word up! Check this out:

strSQL = "Select album name, songname1 From Query/Table Where album name = '" & listbox1.Text & "'

adorecordset3.Open strSQL, adoconnection

If Not adorecordset3.EOF Then
While Not adorecordset3.EOF
listboxsongname.AddItem adorecordset3.Fields("songname1")
adorecoreset3.MoveNext
wend
End If

You may also want to consider throwing the selected item in the list box into a variable and use that in the sql expression. This code is off the top of my head, and in theory will work but you may have to plaly around syntactically with it. Let me know if you run into any other probs.

Laterz,
Jack
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top