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

List Box to make SQL selection

Status
Not open for further replies.

spinachxyz

Programmer
Joined
Apr 20, 2009
Messages
3
Location
GB
Hello guys – hope you can help.

I have a form list box “EventList” consisting of 2 columns, Event and DateX populated from the table TT_Times. Event is not unique so I can have two rows with the same Event but different dates. I want to click on one of these and then have displayed in another list box a selection of data. I have the SQL –

strSQL = "SELECT Event, Distance, Datex, Course, Name, Club, Time, Category
FROM TT_Times
WHERE Event ='" & Forms!Times!EventList & "'
ORDER BY Datex DESC, Time;"

and that works fine but of course selects both my rows that have the same Event name but different dates.

How do I bring the date into the selection. I need to do something like –

strSQL = "SELECT Event, Distance, Datex, Course, Name, Club, Time, Category
FROM TT_Times
WHERE Event ='" & Forms!Times!EventList & "' AND Datex ='" & Forms!Times!EventList.?????? & "'
ORDER BY Time;"

but I’ve no idea what the ?????? is/could/should be.

Regards
Phil
 
Have a look at the Column() property of the listbox.

Hope this helps

HarleyQuinn
---------------------------------
You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
Thanks Harley - I'm sure I did but I'll have another go - Phil
 
Works a treat Harley - thanks. Maybe I got the syntax wrong the first time I tried ! # around the date literal for example. Anyway, OK now
 
Glad I could help [smile]

HarleyQuinn
---------------------------------
You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top