Print Page | Close Window

Submit Form and Redirect to Entry Details?

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=28879
Printed Date: 28 March 2026 at 2:24am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Submit Form and Redirect to Entry Details?
Posted By: kennywhite
Subject: Submit Form and Redirect to Entry Details?
Date Posted: 28 September 2010 at 8:54pm
Hello,

After a user fills out a form, I want them to be redirected to a page showing the data they just entered, so it can be printed. Is that doable? 

Here is the page that processes the user's input. Everything works, except for the redirect at the bottom.

<%
'Dimension variables
Dim adoCon          'Holds the Database Connection Object
Dim rsAddirr   'Holds the recordset for the new record to be added
Dim strSQL          'Holds the SQL query to query the database




'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("irr.mdb")

'Create an ADO recordset object
Set rsAddirr = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT irr.Receiver, irr.BOLTracking, irr.Carrier, irr.InternalPart, 

irr.VendorPart, irr.POQTY, irr.PackQTY, irr.PhysicalQTY, irr.ShortQTY, irr.OverQTY, 

irr.Notes, irr.Location, irr.Date, irr.Day, irr.Month, irr.Year, irr.IssueType, irr.PO, 

irr.Order, irr.Serials, irr.DescrepType, irr.StorageLoc, irr.DamagedQTY, irr.USDIR, 

irr.ProductMovement FROM irr;"

'Set the cursor type we are using so we can navigate through the recordset
rsAddirr.CursorType = 2

'Set the lock type so that the record is locked by ADO when it is updated
rsAddirr.LockType = 3

'Open the recordset with the SQL query 
rsAddirr.Open strSQL, adoCon

'Tell the recordset we are adding a new record to it
rsAddirr.AddNew

'Add a new record to the recordset
rsAddirr.Fields("Receiver") = Request.Form("Receiver")
rsAddirr.Fields("BOLTracking") = Request.Form("BOLTracking")
rsAddirr.Fields("Carrier") = Request.Form("Carrier")
rsAddirr.Fields("InternalPart") = Request.Form("InternalPart")
rsAddirr.Fields("VendorPart") = Request.Form("VendorPart")
rsAddirr.Fields("POQTY") = Request.Form("POQTY")
rsAddirr.Fields("PackQTY") = Request.Form("PackQTY")
rsAddirr.Fields("PhysicalQTY") = Request.Form("PhysicalQTY")
rsAddirr.Fields("ShortQTY") = Request.Form("ShortQTY")
rsAddirr.Fields("OverQTY") = Request.Form("OverQTY")
rsAddirr.Fields("Notes") = Request.Form("Notes")
rsAddirr.Fields("Location") = Request.Form("Location")
rsAddirr.Fields("Date") = Request.Form("Date")
rsAddirr.Fields("Day") = Request.Form("Day")
rsAddirr.Fields("Year") = Request.Form("Year")
rsAddirr.Fields("IssueType") = Request.Form("IssueType")
rsAddirr.Fields("DescrepType") = Request.Form("DescrepType")
rsAddirr.Fields("StorageLoc") = Request.Form("StorageLoc")
rsAddirr.Fields("Month") = Request.Form("Month")
rsAddirr.Fields("PO") = Request.Form("PO")
rsAddirr.Fields("Order") = Request.Form("Order")
rsAddirr.Fields("Serials") = Request.Form("Serials")
rsAddirr.Fields("DamagedQTY") = Request.Form("DamagedQTY")
rsAddirr.Fields("USDIR") = Request.Form("USDIR")



rsAddirr.Fields("ProductMovement") = Request.Form("ProductMovement")



'Write the updated recordset to the database
rsAddirr.Update

'Reset server objects
rsAddirr.Close
Set rsAddirr = Nothing
Set adoCon = Nothing

'Redirect to the default.asp page
Response.Redirect "returndetails.asp?ID=<% Request.Form("ID") %>"
%> 








Thanks for looking!



Replies:
Posted By: WebWiz-Bruce
Date Posted: 29 September 2010 at 9:47am
It should be:-

Response.Redirect "returndetails.asp?ID=" & Request.Form("ID")


-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: kennywhite
Date Posted: 29 September 2010 at 2:23pm
Geesh... Okay, that was an obvious mistake. I fixed that per the above post, but I get the following error:

Error Type:
ADODB.Field (0x80020009)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/receiving/irr/returndetails.asp

The ID number is not inserted in the address bar. It attempts to load returndetails.asp?ID= instead of returndetails.asp?ID=XXXX

Since the ID number is generated automatically in MS Access will I be able to use it on this page?

Thanks.


Posted By: WebWiz-Bruce
Date Posted: 29 September 2010 at 2:30pm
What you would do to read back in the ID number from the database for the new record is to change your SQL Query to have an order by caluse to order the database by ID Desc

Then after the rsAddirr.Update line add rsAddirr.Requery, this will requery the database returning the new record with the newly created ID, you can then read in the ID for the new record from the recordset.


-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: kennywhite
Date Posted: 29 September 2010 at 5:42pm
Still no luck. It is still giving me the same error and not adding the ID# to the URL.

To verify, here is what I changed.

strSQL = "SELECT irr.Receiver, irr.BOLTracking, irr.Carrier, irr.InternalPart, irr.VendorPart, irr.POQTY,
 irr.PackQTY, irr.PhysicalQTY, irr.ShortQTY, irr.OverQTY, irr.Notes, irr.Location, irr.Date, irr.Day,
 irr.Month, irr.Year, irr.IssueType, irr.PO, irr.Order, irr.Serials, irr.DescrepType, irr.StorageLoc,
 irr.DamagedQTY, irr.USDIR, irr.RMA FROM irr ORDER BY ID Desc;"
and
rsAddirr.Update

rsAddirr.Requery

'Reset server objects
rsAddirr.Close
Set rsAddirr = Nothing
Set adoCon = Nothing

'Redirect to the default.asp page
Response.Redirect "returndetails.asp?ID=" & Request.Form("ID")
%> 



Posted By: WebWiz-Bruce
Date Posted: 30 September 2010 at 9:45am
You are reading in the ID from the database not the form.

What you need to do is add your ID field name to the SELECT part of your SQL Query, then after you requery the database youy need to read in the new database ID from the database.

EG:-

SELECT irr.ID, irr.Receiver.........

Then after rsAddirr.Requery you need to read in this new ID value returned by the database and place it into a variable:-

lngID = rsAddirr("ID")

You can then use the ID value in the variable to redirect to your new page.

Response.Redirect "returndetails.asp?ID=" & lngID 


-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: kennywhite
Date Posted: 30 September 2010 at 3:00pm
That works great.

sorry to be so noob-like and thanks for your patience.


Posted By: kennywhite
Date Posted: 11 October 2010 at 3:07pm
Quick question about this. If two users hit submit at the exact same time, is it possible that one could get redirected to the other's data?

If that is possible, is there another method of doing this?


Posted By: kennywhite
Date Posted: 11 October 2010 at 4:21pm
I tried using this instead. 

rsAddirr.Update
lngID = rsAddirr("ID")

I believe this will ensure that I am always pulling the right ID, no matter what.


Posted By: dpyers
Date Posted: 12 October 2010 at 11:50am
Originally posted by kennywhite kennywhite wrote:

Quick question about this. If two users hit submit at the exact same time, is it possible that one could get redirected to the other's data?

If that is possible, is there another method of doing this?

No. Each user has a separate session and executes any script in it's own session space. You can't send information cross-session without getting really tricky.




-------------

Lead me not into temptation... I know the short cut, follow me.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net