Update Multiple Records with One submit

O

Olivia Towery

SQL 6.5 Database

I have a list of registrants and I want to use a check box after each record
to show those who attend and then post all with one submit button.

Any help is appreciated.
 
T

Tom B

You can loop through your results, and send an update for each one. Do you
need to update those who don't attend?

I'll assume you don't have to update those who don't.

So on your form you'd have.....

Joe Blow <input type=checkbox name=ATTENDED value=1>
Fred Smith <input type=checkbox name=ATTENDED value=8>
Jen Jones <input type=checkbox name=ATTENDED value=3>
Gerald Springer<input type=checkbox name=ATTENDED value=99>

(Note that the value is the registrants ID from the database)

When the page is submitted the value of Request.Form("ATTENDED") will be a
comma delimited string of the selected values, so assuming just Joe, Jen and
Gerald are checked then it would equal "1,8,99" So, split it into an array
and update the database


Dim arrRegistrants
Dim iLoop
Dim sSQL
arrRegistrants=Split(Request.Form("ATTENDED"),",")

for iLoop=0 to Ubound(arrRegistrants)
sSQL="UPDATE tblWhatever Set Attended=1 WHERE RegistrantID=" &
arrRegistrants(iLoop)
CN.Execute sSQL 'Assuming CN is a valid and open connection object
next


You could also send a single sql statement along the lines of

sSQL="UPDATE tblWhatever SET Attended=1 WHERE RegistrantID IN (" &
Request.Form("ATTENDED") & ")"

which would look like this
UPDATE tblWhatever SET Attended=1 WHERE RegistrantID IN (1,8,99)

I think that's right, check BOL.
 
O

Olivia Towery

Thanks Tom. But what if I do want to be able to uncheck a box and have the
db updated? Can this be done?
 

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,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top