ianripping
02-21-2004, 06:54 AM
Hi I have an asp form which delivers its infor to an acess file.
Then I have an asp database reader.
This open's up the first forms information, I want a button that will delete this form and then open up the next record.
Can this be done?
buntine
02-21-2004, 07:21 AM
Yes, its quite simple really.
Use an auto-number ID field in your database. When 'delete' button has been submitted, have a hidden form control send across the ID number of the record which is to be removed from the Access Database.
The following code snippet may be of interest to you.
response.buffer = true
dim intID
dim sql_query
intID = request.form("idnum")
sql_query = "DELETE * FROM tableName WHERE ID = " & intID
conn.execute(sql_query)
response.redirect(Split(request.serverVariables("HTTP_REFERER"),"?")(0) & "?recordnum=" & intID + 1)
request.form("idnum") refers to a hidden form control which goes by the name of 'idnum'.
conn.execute(sql_query) will execute the sql query. Ensure your have created a connection object named 'conn'
response.redirect(Split(request.serverVariables("HTTP_REFERER"),"?")(0) & "?recordnum=" & intID + 1) will redirect the user back to the refering ASP page and display the next record, provided you have coded the page so it displays a certain record depending on the queryString value.
Regards,
Andrew Buntine.