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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cancel Redirect, check recordset

Status
Not open for further replies.

ShawnDT

Technical User
May 1, 2006
67
US
Good Afternoon,

I am trying to after a user press the cancel button on my insert page, it clears the form and then checks to see if the recordset is empty. If it is empty it stays on the insert page if not it redirects itself to another page. Is this possible, if so can an example code be given?


I posted my code below.


<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/connDB.asp" -->
<!--#include file="functions.asp"-->

<% If Request("butSaveUpdate") <> "" Then %>

<%

Dim CmdInsert__ProducerID
CmdInsert__ProducerID = ""
if(Request("ProducerID") <> "") then CmdInsert__ProducerID = Request("ProducerID")

Dim CmdInsert__LastName
CmdInsert__LastName = ""
if(Request("LastName") <> "") then CmdInsert__LastName = Request("LastName")

Dim CmdInsert__FirstName
CmdInsert__FirstName = ""
if(Request("FirstName") <> "") then CmdInsert__FirstName = Request("FirstName")

Dim CmdInsert__PreferredName
CmdInsert__PreferredName = ""
if(Request("PreferredName") <> "") then CmdInsert__PreferredName = Request("PreferredName")

Dim CmdInsert__Title
CmdInsert__Title = ""
if(Request("Title") <> "") then CmdInsert__Title = Request("Title")

Dim CmdInsert__Phone
CmdInsert__Phone = null
if(Request("Phone") <> "") then CmdInsert__Phone = fnparsePhoneNumber (Request("Phone"))

Dim CmdInsert__Ext
CmdInsert__Ext = ""
if(Request("Ext") <> "") then CmdInsert__Ext = Request("Ext")

Dim CmdInsert__Email
CmdInsert__Email = ""
if(Request("Email") <> "") then CmdInsert__Email = Request("Email")

Dim CmdInsert__Notes
CmdInsert__Notes = ""
if(Request("Notes") <> "") then CmdInsert__Notes = Request("Notes")

%>
<%

set CmdInsert = Server.CreateObject("ADODB.Command")
CmdInsert.ActiveConnection = MM_connDB_STRING
CmdInsert.CommandText = "dbo.spProducerContactInsert"
CmdInsert.CommandType = 4
CmdInsert.CommandTimeout = 0
CmdInsert.Prepared = true
CmdInsert.Parameters.Append CmdInsert.CreateParameter("@RETURN_VALUE", 3, 4)
CmdInsert.Parameters.Append CmdInsert.CreateParameter("@ProducerID", 3, 1,4,CmdInsert__ProducerID)
CmdInsert.Parameters.Append CmdInsert.CreateParameter("@LastName", 200, 1,50,CmdInsert__LastName)
CmdInsert.Parameters.Append CmdInsert.CreateParameter("@FirstName", 200, 1,30,CmdInsert__FirstName)
CmdInsert.Parameters.Append CmdInsert.CreateParameter("@PreferredName", 200, 1,30,CmdInsert__PreferredName)
CmdInsert.Parameters.Append CmdInsert.CreateParameter("@Title", 200, 1,50,CmdInsert__Title)
CmdInsert.Parameters.Append CmdInsert.CreateParameter("@Phone", 20, 1,14,CmdInsert__Phone)
CmdInsert.Parameters.Append CmdInsert.CreateParameter("@Ext", 200, 1,5,CmdInsert__Ext)
CmdInsert.Parameters.Append CmdInsert.CreateParameter("@Email", 200, 1,50,CmdInsert__Email)
CmdInsert.Parameters.Append CmdInsert.CreateParameter("@Notes", 200, 1,500,CmdInsert__Notes)
CmdInsert.Execute()
Response.redirect "producerdetail_contacts.asp?ProducerID=" + cmdInsert__ProducerID
%>
<% End If %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function fnCancelInsert() {
// Reset all fields on Insert form
document.frmInsert.reset();

}
//-->
</script>
<style type="text/css">
<!--
@import url("CSS/NRCG.css");
-->
</style>
</head>

<body>
<form id="frmInsert" name="frmInsert" method="post" action="">
<table width="500" border="0" cellspacing="2" cellpadding="2">
<tr>
<td width="150">&nbsp;</td>
<td width="250">&nbsp;</td>
<td width="50"><input name="butSaveUpdate" type="submit" class="Nav" id="butSaveUpdate" value="Save" /></td>
<td width="50"><input name="butCancelInsert" type="button" class="Nav" id="butCancelInsert" value="Cancel" onclick="javascript:fnCancelInsert();" /></td>
</tr>
<tr>
<td><label>Name (F/L)</label>
</td>
<td colspan="3"><input name="FirstName" type="text" id="FirstName" />
&nbsp;&nbsp;&nbsp;&nbsp;
<input name="LastName" type="text" id="LastName" /></td>
</tr>
<tr>
<td><label>Preferred Name</label>
</td>
<td colspan="3"><input name="PreferredName" type="text" id="PreferredName" />
<input name="producerID" type="hidden" id="producerID" /></td>
</tr>
<tr>
<td><label>Title</label></td>
<td colspan="3"><input name="Title" type="text" id="Title" />
</td>
</tr>
<tr>
<td><label>Phone/Ext</label></td>
<td colspan="3"><input name="Phone" type="text" id="Phone" />
&nbsp;/&nbsp;&nbsp;
<input name="Ext" type="text" id="Ext" />
</td>
</tr>
<tr>
<td><label>E-mail</label></td>
<td colspan="3"><input name="Email" type="text" id="Email" /></td>
</tr>
<tr>
<td><label>Notes</label></td>
<td colspan="3"><input name="Notes" type="text" id="Notes" /></td>
</tr>
</table>
</form>
</body>
</html>
 
hmm not quite sure where this is going...why would you let them know that there is no records Especially after they didn't submit anything?
a plea for submittion?
write more about logical process of this...

All the best!

:--------------------------------------:
fugitive.gif


All around in my home town,
They tryin' to track me down...
 
If they have pressed the cancel button no record will have been written, unless you are trying to capture a user that has hit the back button after inserting. But we are trying to guess at what you are trying to achieve when you could just tell us and then we may be able to help

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

Part and Inventory Search

Sponsor

Back
Top