Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Submit Form and Redirect to Entry Details?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Submit Form and Redirect to Entry Details?

 Post Reply Post Reply Page  12>
Author
kennywhite View Drop Down
Groupie
Groupie


Joined: 26 February 2009
Location: Indy
Status: Offline
Points: 106
Post Options Post Options   Thanks (0) Thanks(0)   Quote kennywhite Quote  Post ReplyReply Direct Link To This Post Topic: Submit Form and Redirect to Entry Details?
    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!
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post Posted: 29 September 2010 at 9:47am
It should be:-

Response.Redirect "returndetails.asp?ID=" & Request.Form("ID")
Back to Top
kennywhite View Drop Down
Groupie
Groupie


Joined: 26 February 2009
Location: Indy
Status: Offline
Points: 106
Post Options Post Options   Thanks (0) Thanks(0)   Quote kennywhite Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
kennywhite View Drop Down
Groupie
Groupie


Joined: 26 February 2009
Location: Indy
Status: Offline
Points: 106
Post Options Post Options   Thanks (0) Thanks(0)   Quote kennywhite Quote  Post ReplyReply Direct Link To This Post 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")
%> 

Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post 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 
Back to Top
kennywhite View Drop Down
Groupie
Groupie


Joined: 26 February 2009
Location: Indy
Status: Offline
Points: 106
Post Options Post Options   Thanks (0) Thanks(0)   Quote kennywhite Quote  Post ReplyReply Direct Link To This Post Posted: 30 September 2010 at 3:00pm
That works great.

sorry to be so noob-like and thanks for your patience.
Back to Top
kennywhite View Drop Down
Groupie
Groupie


Joined: 26 February 2009
Location: Indy
Status: Offline
Points: 106
Post Options Post Options   Thanks (0) Thanks(0)   Quote kennywhite Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.