probably easy for you, but . . .

M

middletree

Over the years, believe it or not, I have never used Multiple select boxes.
Now, can someone tell me where I can see some sample code for how to get
data from there and use it? Specifically, the select box will list the first
and last names of employees (this is Intranet), and I want to take the
employee ID (which would be the value of each selection) and use it on the
next page to go back into the employee table of the database and pull up
their email address, send emails using CDO, store the fact that an email was
sent into the database, etc.

I do better with sample code than philosophical explanations.

thanks
 
A

Aaron Bertrand - MVP

A multiple select box gives a comma-separated list of chosen values. So
something as simple as:

sql = "SELECT * FROM table WHERE employeeID IN (" &
request.form("employeeID") & ")"

Now, it would be more complicated if these were strings, because you'd have
to insert delimiters. And don't forget earlier discussions about preventing
SQL injection...

A
 
A

Aaron Bertrand - MVP

Ok, so if a user selects two people from the list, and the values are 100
and 200, then the Select statement would be

sql = "SELECT * FROM table WHERE employeeID IN ("100,200")"

Well, close... the embedded quotes wouldn't be there.
And then I would have to find a way to grab the email address (or whatever
info I need) from that table for both employee 100 and employee 200. Can you
guide me on this? This is the part about which I am most confused.

sql = "SELECT employeeID, emailAddress FROM table WHERE employeeID IN (100,
200)"
set rs = conn.execute(sql)
do while not rs.eof
response.write "EmployeeID " & rs(0) & " e-mail:"
response.write rs(1) & "<br>"
rs.movenext
loop
 
M

middletree

OK, that makes sense. I appreciate it!


Aaron Bertrand - MVP said:
Well, close... the embedded quotes wouldn't be there.


sql = "SELECT employeeID, emailAddress FROM table WHERE employeeID IN (100,
200)"
set rs = conn.execute(sql)
do while not rs.eof
response.write "EmployeeID " & rs(0) & " e-mail:"
response.write rs(1) & "<br>"
rs.movenext
loop
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top