Hi Hope someone can help me with this.
When I ask to redirect to another page if the data being entered via a particular form field "Centre" to the Access DB is duplicated it will only see the first record and redirect if that is duplicated. If the form field "Centre" data entered into the form is duplicated past the first record i get a "page cannot be displayed" with the message: "The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship."
Code is:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!-- #include file = "../includes/LOGINNOW.ASP" -->
<!--#include file="../includes/connection.asp" -->
<%
' Declare variables
Dim Conn
Dim RS
Dim SQL
Dim strID
'create connection object
Set Conn=Server.CreateObject("ADODB.Connection"
Conn.Open Openvar
'create recordset object
Set RS=Server.CreateObject("ADODB.RecordSet"
'set and assign structured query statement to variable
SQL="SELECT * FROM Centre"
'opens the table to view all records and open and lock modes
RS.Open SQL, Conn, 3,3
%>
<%
If Request.Form("Centre"
=RS("CentreName"
Then
Response.Redirect "duplicate_centredept.asp"
End If
%>
<%
Thisday = CStr(Date) ' Get todays date.
%>
<%
'AddNew method of recordset to add a record
RS.AddNew
'input to recordset from form data
RS("CentreName"
= Request.Form("Centre"
RS("Address"
= Request.Form("Address"
RS("City"
= Request.Form("City"
RS("Postcode"
= Request.Form("Postcode"
RS("TelNo"
= Request.Form("TelNo"
RS("FaxNo"
= Request.Form("FaxNo"
RS.Update
'MoveLast gets the Centre ID number that is automatically generated by database
' A local variable is set so that I can write out the ID number from the database
RS.MoveLast
strID = RS("CentreName"
'Code for assigning variable to ASP date
thisDay = CStr(Date)
%>
Cheers for any help.
When I ask to redirect to another page if the data being entered via a particular form field "Centre" to the Access DB is duplicated it will only see the first record and redirect if that is duplicated. If the form field "Centre" data entered into the form is duplicated past the first record i get a "page cannot be displayed" with the message: "The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship."
Code is:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!-- #include file = "../includes/LOGINNOW.ASP" -->
<!--#include file="../includes/connection.asp" -->
<%
' Declare variables
Dim Conn
Dim RS
Dim SQL
Dim strID
'create connection object
Set Conn=Server.CreateObject("ADODB.Connection"
Conn.Open Openvar
'create recordset object
Set RS=Server.CreateObject("ADODB.RecordSet"
'set and assign structured query statement to variable
SQL="SELECT * FROM Centre"
'opens the table to view all records and open and lock modes
RS.Open SQL, Conn, 3,3
%>
<%
If Request.Form("Centre"
Response.Redirect "duplicate_centredept.asp"
End If
%>
<%
Thisday = CStr(Date) ' Get todays date.
%>
<%
'AddNew method of recordset to add a record
RS.AddNew
'input to recordset from form data
RS("CentreName"
RS("Address"
RS("City"
RS("Postcode"
RS("TelNo"
RS("FaxNo"
RS.Update
'MoveLast gets the Centre ID number that is automatically generated by database
' A local variable is set so that I can write out the ID number from the database
RS.MoveLast
strID = RS("CentreName"
'Code for assigning variable to ASP date
thisDay = CStr(Date)
%>
Cheers for any help.