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

Record Amend Problems in Access DB

Status
Not open for further replies.

kefi2927

IS-IT--Management
Apr 3, 2003
40
GB
Hi
Can anyone help me with this?

The page i'm working on allows me to amend the CentreName field in the DB from the CentreName field in a form. Or it allows me to check wether the CentreName is duplicated and then redirects the user to another page to let them know that it is a duplicate.

But can't figure out how to be able to leave the CentreName field alone and alter another filed within that record say 'Address' Without the user being redirected to the page that tells them this is a duplicate, because the CentreName field has stayed the same??

<%@LANGUAGE=&quot;VBSCRIPT&quot; CODEPAGE=&quot;1252&quot;%>
<!-- #include file = &quot;../includes/ADOVBS.INC&quot; -->
<!-- #include file = &quot;../includes/LOGINNOW.ASP&quot; -->
<!--#include file=&quot;../includes/connection.asp&quot; -->

<%
Dim Conn
Dim RS
Dim SQL
Dim searchTerm

'create connection object
Set Conn=Server.CreateObject(&quot;ADODB.Connection&quot;)
Conn.Open Openvar

'Get record EmployeeID from QueryString
searchTerm = Request.QueryString(&quot;CentreName&quot;)

'set and assign structured query statement to variable
SQL=&quot;SELECT * FROM Centre WHERE Centre.CentreName LIKE '%&quot; &searchTerm& &quot;%' &quot;

'create recordset object
Set RS=Server.CreateObject(&quot;ADODB.RecordSet&quot;)

'opens the table to view all records and open and lock modes
RS.Open SQL, Conn, 3,3


Thisday = CStr(Date) ' Get todays date.


'This will test if the Centre field is left blank
If Request.Form(&quot;CentreName&quot;) = &quot;&quot; Then
Response.Redirect &quot;duplicate_centredept.asp&quot;
Else



'This will test if the Centre field entered is duplicated data in Centre table
strCentreSQL=&quot;SELECT CentreName FROM Centre WHERE CentreName = '&quot; & Request.Form(&quot;CentreName&quot;) & &quot;'&quot;
Set rsCentre = conn.Execute(strCentreSQL)


If rsCentre.EOF then

%>

<%
RS (&quot;CentreName&quot;)=Request.Form(&quot;CentreName&quot;)
RS (&quot;Address&quot;)=Request.Form(&quot;Address&quot;)
RS (&quot;City&quot;)=Request.Form(&quot;City&quot;)
RS (&quot;Postcode&quot;)=Request.Form(&quot;Postcode&quot;)
RS (&quot;TelNo&quot;)=Request.Form(&quot;TelNo&quot;)
RS (&quot;FaxNo&quot;)=Request.Form(&quot;FaxNo&quot;)

RS.Update

%>

<table>
<tr>
<td class=&quot;dataHeader&quot;>Centre Name</td>
<td class=&quot;dataHeader&quot;>Address</td>
<td class=&quot;dataHeader&quot;>City</td>
<td class=&quot;dataHeader&quot;>Postcode</td>
<td class=&quot;dataHeader&quot;>Tel No</td>
<td class=&quot;dataHeader&quot;>Fax No</td>
</tr>
<tr>
<td class=&quot;dataContent&quot;><%=RS(&quot;CentreName&quot;)%></td>
<td class=&quot;dataContent&quot;><%=RS(&quot;Address&quot;)%></td>
<td class=&quot;dataContent&quot;><%=RS(&quot;City&quot;)%></td>
<td class=&quot;dataContent&quot;><%=RS(&quot;Postcode&quot;)%></td>
<td class=&quot;dataContent&quot;><%=RS(&quot;TelNo&quot;)%></td>
<td class=&quot;dataContent&quot;><%=RS(&quot;FaxNo&quot;)%></td>
</tr>

</table>
<%



Else
Response.Redirect &quot;duplicate_centredept.asp&quot;
End If 'rsCentre.EOF

End If 'Request.Form(&quot;Centre&quot;) = &quot;&quot;

%>

Thanks for anybody's help with this.
 
Could you do something like this. If there is a duplicate record found, instead of going right to the duplicate record found page, maybe go to a page that gives the user a chioce. For example if the record already exists in the DB you could direct them to a page that says that record already exists, would you like to enter another record or edit the existing one. Something like that. hope that helped.
 
<%
Dim Conn
Dim RS
Dim SQL
Dim searchTerm

searchTerm = Request.QueryString(&quot;CentreName&quot;)
If searchTerm = &quot;&quot; Then Response.Redirect &quot;duplicate_centredept.asp&quot;

Thisday = CStr(Date)

Set Conn=Server.CreateObject(&quot;ADODB.Connection&quot;)
Set rsCentre = conn.Execute(strCentreSQL)
SQL=&quot;SELECT CentreName FROM Centre WHERE CentreName = '&quot; & searchTerm & &quot;'&quot;
RS.Open SQL, Conn, 3,3


If RS.EOF then
RS(&quot;CentreName&quot;)=Request(&quot;CentreName&quot;)
RS(&quot;Address&quot;)=Request(&quot;Address&quot;)
RS(&quot;City&quot;)=Request(&quot;City&quot;)
RS(&quot;Postcode&quot;)=Request(&quot;Postcode&quot;)
RS(&quot;TelNo&quot;)=Request(&quot;TelNo&quot;)
RS(&quot;FaxNo&quot;)=Request(&quot;FaxNo&quot;)
RS.Update
Call DisplayData()
Else
RS(&quot;Address&quot;)=Request(&quot;Address&quot;)
RS(&quot;City&quot;)=Request(&quot;City&quot;)
RS(&quot;Postcode&quot;)=Request(&quot;Postcode&quot;)
RS(&quot;TelNo&quot;)=Request(&quot;TelNo&quot;)
RS(&quot;FaxNo&quot;)=Request(&quot;FaxNo&quot;)
RS.Update
Call DisplayData()
End If


Sub DisplayData()%>
<table><tr>
<td class=&quot;dataHeader&quot;>Centre Name</td>
<td class=&quot;dataHeader&quot;>Address</td>
<td class=&quot;dataHeader&quot;>City</td>
<td class=&quot;dataHeader&quot;>Postcode</td>
<td class=&quot;dataHeader&quot;>Tel No</td>
<td class=&quot;dataHeader&quot;>Fax No</td></tr><tr>
<td class=&quot;dataContent&quot;><%=RS(&quot;CentreName&quot;)%></td>
<td class=&quot;dataContent&quot;><%=RS(&quot;Address&quot;)%></td>
<td class=&quot;dataContent&quot;><%=RS(&quot;City&quot;)%></td>
<td class=&quot;dataContent&quot;><%=RS(&quot;Postcode&quot;)%></td>
<td class=&quot;dataContent&quot;><%=RS(&quot;TelNo&quot;)%></td>
<td class=&quot;dataContent&quot;><%=RS(&quot;FaxNo&quot;)%></td></tr>
</table>
<%end sub%>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top