Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pass key value to redirected page after update.

Status
Not open for further replies.

Ammodog

Technical User
Dec 13, 2002
97
0
0
US
I am using asp and an access db. Can someone tell me how to pass a key value to my redirection page after an update form. I have tried to insert a hidden field and bring it over with Request.QueryString("transid") but I think I am missing something. Thanks


Christopher Abney
There is no limit to the good you can do if you dont care who gets the credit
 
just use an asp variable to pass the string, in the redirect to field just put something like
Code:
yourpage.asp?key=<%=strVariable%>
just make sure to assign the variable before this

Cheech

[Peace][Pipe]
 
When I put that in my redirect field it gives me an error saying no table found. This is what I placed in the after update go to translis.asp?transid=<%=(rsval.Fields.Item("transactionid").Value)%>


here is my page code if that helps.. transid is the key i want to pass.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/fbt.asp" -->
<%
' *** Edit Operations: declare variables

Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd

Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId

Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i

MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>
<%
' *** Update Record: set variables

If (CStr(Request("MM_update")) = "form1" And CStr(Request("MM_recordId")) <> "") Then

MM_editConnection = MM_fbt_STRING
MM_editTable = "tbltransactions"
MM_editColumn = "transactionid"
MM_recordId = "" + Request.Form("MM_recordId") + ""
MM_editRedirectUrl = "home.asp"
MM_fieldsStr = "datedue|value|datepostmarked|value|linea|value|lineb|value|linec|value|lined|value|linee|value|linef|value|lineg|value|lineh|value|linehexplain|value|linei|value|lastofvalidated|value"
MM_columnsStr = "datedue|',none,NULL|datepostmarked|',none,NULL|linea|',none,''|lineb|',none,''|linec|',none,''|lined|',none,''|linee|',none,''|linef|',none,''|lineg|',none,''|lineh|',none,''|linehexplain|',none,''|linei|',none,''|validated|none,1,0"

' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")

' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next

' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If

End If
%>
<%
' *** Update Record: construct a sql update statement and execute it

If (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "") Then

' create the sql update statement
MM_editQuery = "update " & MM_editTable & " set "
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),",")
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_editQuery = MM_editQuery & ","
End If
MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
Next
MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId

If (Not MM_abortEdit) Then
' execute the update
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If

End If
%>
<%
Dim rsval
Dim rsval_numRows

Set rsval = Server.CreateObject("ADODB.Recordset")
rsval.ActiveConnection = MM_fbt_STRING
rsval.Source = "SELECT * FROM qrylastoftransactions"
rsval.CursorType = 0
rsval.CursorLocation = 2
rsval.LockType = 1
rsval.Open()

rsval_numRows = 0
%>
<%
Dim rsvalid
Dim rsvalid_numRows

Set rsvalid = Server.CreateObject("ADODB.Recordset")
rsvalid.ActiveConnection = MM_fbt_STRING
rsvalid.Source = "SELECT * FROM qryvalid"
rsvalid.CursorType = 0
rsvalid.CursorLocation = 2
rsvalid.LockType = 1
rsvalid.Open()

rsvalid_numRows = 0
%>
<%
Dim rsval2
Dim rsval2_numRows

Set rsval2 = Server.CreateObject("ADODB.Recordset")
rsval2.ActiveConnection = MM_fbt_STRING
rsval2.Source = "SELECT * FROM qrylastoftransactions"
rsval2.CursorType = 0
rsval2.CursorLocation = 2
rsval2.LockType = 1
rsval2.Open()

rsval2_numRows = 0
%>
<SCRIPT>
function DoCal(elTarget) {
if (showModalDialog) {
var sRtn;
sRtn = showModalDialog("Calendar.htm","","center=yes;dialogWidth=350pt;dialogHeight=200pt");
if (sRtn!="")
elTarget.value = sRtn;
} else
alert("Internet Explorer 4.0 or later is required.")
}
</SCRIPT>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
.style2 {color: #FF0000}
-->
</style></head>

<body>
<form ACTION="<%=MM_editAction%>" METHOD="POST" name="form1">
<table width="431" border="1" align="center">
<tr bgcolor="#0000FF">
<td colspan="3"><div align="center"><strong><span class="style1">Correct all fields and click validate </span></strong></div></td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td width="132"><div align="left"><strong>Date Due </strong></div></td>
<td width="183"><INPUT NAME=datedue TYPE=text id="datedue" value="<%=(rsval2.Fields.Item("LastOfdatedue").Value)%>">
<INPUT name="button" TYPE=button ONCLICK="DoCal(this.form.datedue)" VALUE="Choose Date">
&nbsp;</td>
<td width="175" rowspan="2" bgcolor="#0000FF"><div align="center" class="style1"><strong>Validation</strong></div></td>
</tr>
<tr>
<td><div align="left"><strong>Date Postmarked </strong></div></td>
<td><INPUT NAME=datepostmarked TYPE=text id="datepostmarked" value="<%=(rsval2.Fields.Item("LastOfdatepostmarked").Value)%>">
<INPUT TYPE=button VALUE="Choose Date" ONCLICK="DoCal(this.form.datepostmarked)">
&nbsp;</td>
</tr>
<tr>
<td><div align="left"><strong>Line A </strong></div></td>
<td><input name="linea" type="text" id="linea" value="<%= FormatCurrency((rsval2.Fields.Item("LastOflinea").Value), -1, -2, -2, -2) %>"></td>
<td><strong><%= FormatCurrency((rsvalid.Fields.Item("LastOflinea").Value), -1, -2, -2, -2) %></strong></td>
</tr>
<tr>
<td><div align="left"><strong>Line B </strong></div></td>
<td><input name="lineb" type="text" id="lineb" value="<%= FormatCurrency((rsval2.Fields.Item("LastOflineb").Value), -1, -2, -2, -2) %>"></td>
<td><strong><%= FormatCurrency((rsvalid.Fields.Item("LastOflineb").Value), -1, -2, -2, -2) %></strong></td>
</tr>
<tr>
<td><div align="left"><strong>Line C </strong></div></td>
<td><input name="linec" type="text" id="linec" value="<%= FormatCurrency((rsval2.Fields.Item("LastOflinec").Value), -1, -2, -2, -2) %>"></td>
<td><strong><%= FormatCurrency((rsvalid.Fields.Item("LastOfvlinec").Value), -1, -2, -2, -2) %></strong></td>
</tr>
<tr>
<td><div align="left"><strong>Line D </strong></div></td>
<td><input name="lined" type="text" id="lined" value="<%= FormatCurrency((rsval2.Fields.Item("LastOflined").Value), -1, -2, -2, -2) %>"></td>
<td><strong><%= FormatCurrency((rsvalid.Fields.Item("LastOfVlined").Value), -1, -2, -2, -2) %></strong></td>
</tr>
<tr>
<td><div align="left"><strong>Line E </strong></div></td>
<td><input name="linee" type="text" id="linee" value="<%= FormatCurrency((rsval2.Fields.Item("LastOflinee").Value), -1, -2, -2, -2) %>"></td>
<td><strong><%= FormatCurrency((rsvalid.Fields.Item("LastOfvlinee").Value), -1, -2, -2, -2) %></strong></td>
</tr>
<tr>
<td><div align="left"><strong>Line F </strong></div></td>
<td><input name="linef" type="text" id="linef2" value="<%= FormatCurrency((rsval2.Fields.Item("LastOflinef").Value), -1, -2, -2, -2) %>"></td>
<td><strong><%= FormatCurrency((rsvalid.Fields.Item("LastOfvlinef").Value), -1, -2, -2, -2) %></strong></td>
</tr>
<tr>
<td><div align="left"><strong>Line G </strong></div></td>
<td><input name="lineg" type="text" id="lineg" value="<%= FormatCurrency((rsval2.Fields.Item("LastOflineg").Value), -1, -2, -2, -2) %>"></td>
<td><strong><%= FormatCurrency((rsvalid.Fields.Item("lineg2").Value), -1, -2, -2, -2) %></strong></td>
</tr>
<tr>
<td><div align="left"><strong>Line H </strong></div></td>
<td><input name="lineh" type="text" id="lineh" value="<%= FormatCurrency((rsval2.Fields.Item("LastOflineh").Value), -1, -2, -2, -2) %>"></td>
<td><strong><%= FormatCurrency((rsvalid.Fields.Item("lineh2").Value), -1, -2, -2, -2) %></strong></td>
</tr>
<tr>
<td><div align="left"><strong>Line H Explanation</strong></div></td>
<td><textarea name="linehexplain" cols="25" rows="6" id="linehexplain"><%=(rsval2.Fields.Item("LastOflinehexplain").Value)%></textarea></td>
<td>&nbsp;</td>
</tr>
<tr>
<td><div align="left"><strong>Line I </strong></div></td>
<td><input name="linei" type="text" id="linei" value="<%= FormatCurrency((rsval2.Fields.Item("LastOflinei").Value), -1, -2, -2, -2) %>"></td>
<td><strong><%= FormatCurrency((rsvalid.Fields.Item("LastOfvlinei").Value), -1, -2, -2, -2) %></strong></td>
</tr>
<tr bgcolor="#FFFFFF">
<td><div align="left"><strong>Difference</strong></div></td>
<td colspan="2"><input name="linei2" type="text" id="linei4" value="<%= FormatCurrency((rsvalid.Fields.Item("Difference").Value), -1, -2, -2, -2) %>">
<span class="style2">* </span> </td>
</tr>
<tr bgcolor="#FFFFFF">
<td colspan="3">* = If a negative number ( )the tax payer owes , If a Positive number the tax payer recieves a refund. Click on the refund link to process refunds.</td>
</tr>
<tr bgcolor="#FFFFFF">
<td><div align="left"><strong>Validated?</strong></div></td>
<td colspan="2"><input name="lastofvalidated" type="checkbox" id="lastofvalidated" value="checkbox"></td>
</tr>
<tr bgcolor="#0000FF">
<td colspan="3">&nbsp;</td>
</tr>
<tr bgcolor="#0000FF">
<td colspan="3"><div align="center">
<input type="submit" name="Submit" value="Update">
</div></td>
</tr>
</table>
<p>
<input name="hiddenField" type="hidden" value="<%=(rsval.Fields.Item("transactionid").Value)%>">
<input name="acctid" type="hidden" id="acctid" value="<%= Request("acctid") %>">
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="MM_recordId" value="<%= rsval2.Fields.Item("transactionid").Value %>">
</p>
</form>
<p>&nbsp;</p>
</body>
</html>
<%
rsval.Close()
Set rsval = Nothing
%>
<%
rsvalid.Close()
Set rsvalid = Nothing
%>
<%
rsval2.Close()
Set rsval2 = Nothing
%>


Christopher Abney
There is no limit to the good you can do if you dont care who gets the credit
 
I can see what you are trying to do now. I would be tempted to take the update behaviour of this page and pass all of the variables to another page and do the insert there. The problem appears to be the order of the code. Your variable is not declared until the page is built and then it processes the update

Cheech

[Peace][Pipe]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top