Delete several dbrecords with check boxes.

T

Ted Ljong

FP 2000 and access 2000

In a 2-frame page:
I display records from an accessdb in frame 1. I want to mark 1 or several
records in order to delete them. I mark them with check boxes but I can't
find out how to send the marked records to the delete page.

Is there anyone that can give me a clue.
Ted Ljong
 
T

Ted Ljong

I rewrite my question.

How to mark 1 or several records from a dbresult and then transfer the
marked records to another page

Ted
 
J

Jim Buyens

You would have to custom-program this in ASP or ASP.NET.
If this is within your capabilities, post again to this
thread, stating which approach you prefer.

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*------------------------------------------------------*
|\----------------------------------------------------/|
|| Microsoft Office FrontPage 2003 Inside Out ||
|| Microsoft FrontPage Version 2002 Inside Out ||
|| Web Database Development Step by Step .NET Edition ||
|| Troubleshooting Microsoft FrontPage 2002 ||
|| Faster Smarter Beginning Programming ||
|| (All from Microsoft Press) ||
|/----------------------------------------------------\|
*------------------------------------------------------*
 
J

Jim Buyens

Ted Ljong said:
Hi Jim
Did I misunderstood you? I appreciate some help with ASP
Ted Ljong.

Well, if you've written your own ASP page to display the existing
records, I presume you open a recordset containing the records you
want, and then run a loop that creates an HTML table row to display
each record. Here's an example.
<form method="POST" action="delete.asp">
<table>
<tr>
<th>ID</th>
<th>Decription</th>
</tr>
</table>
<%
do until rs.eof
%><tr>
<td><%=rs("recid")%></td>
<td><%=rs("description")%></td>
</tr><%
rs.movenext
loop
%>
<input name="bthDel" type="submit" value="Delete">
</form>

Add a column to that table and then, within the loop, emit an
additional table cell that emits the check box. Be sure to include the
identity of each record in the name of the check box. The loop will
now look like this.

do until rs.eof
%><tr>
<td><input type="checkbox" name="del<%=rs("recid")%>"
value="ON"></td>
<td><%=rs("recid")%></td>
<td><%=rs("description")%></td>
</tr><%
rs.movenext
loop

To see how this works, imagine that the visitor selects the check
boxes for record IDs 5, 10, and 20. In the page that processes the
form, the following expressions will then equal ON.

Request.Form("del5")
Request.Form("del10")
Request.Form("del20")

The page that processes the form should therefore contain this code:

if request.form("bthDel") <> "" then
for each name in request.form
if left(name,3) = "del" then
delid = mid(name,4)
sql = "DELETE from mytable WHERE recid = " & delid & " "
conn.Execute sql
response.write "<p>" & delid & "</p>"
end if
next
end if

Note that unchecked boxes transmit nothing. Thus, if the form contains
a checkbox named del17 and the visitor doesn't clear it, there will be
no such name as del17 in the request.form collection.

To "harden" this application you could, however, check each
Request.Form("del...") entry for a value of ON, or whatever you like.
You should also check each record ID for valid syntax.

If this is way over your head, you probably need to read some books or
get some training in ASP or ASP.NET programming. Tutoring by newsgroup
really isn't practical.

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*------------------------------------------------------*
|\----------------------------------------------------/|
|| Microsoft Office FrontPage 2003 Inside Out ||
|| Microsoft FrontPage Version 2002 Inside Out ||
|| Web Database Development Step by Step .NET Edition ||
|| Troubleshooting Microsoft FrontPage 2002 ||
|| Faster Smarter Beginning Programming ||
|| (All from Microsoft Press) ||
|/----------------------------------------------------\|
*------------------------------------------------------*
 
T

Ted Ljong

Thanks Jim
Very kind of you to send this answer, I appreciate it.
As a matter of fact I am reading asp books but it isn´t easy, but this very
educational answer will help me a lot.
Thanks again
Ted Ljong
 

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

Top