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

Search form

Status
Not open for further replies.

redbay

Technical User
Oct 13, 2003
145
GB
second problem for today!

i have a text field on a searchform that searches for names from the customer page, this works OK but when i apply the show region if recordset empty i get the page saying

ADODB.Field (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
i have the last name selected in the recordset on the customer page and the form variable set as the form name from the search form.....any help welcome
 
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/dbConn.asp" -->
<%
Dim rsCustomers
Dim rsCustomers_numRows

Set rsCustomers = Server.CreateObject("ADODB.Recordset")
rsCustomers.ActiveConnection = MM_dbConn_STRING
rsCustomers.Source = "SELECT * FROM qryCustomers ORDER BY CustomerFullName ASC"
rsCustomers.CursorType = 0
rsCustomers.CursorLocation = 2
rsCustomers.LockType = 1
rsCustomers.Open()

rsCustomers_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
rsCustomers_numRows = rsCustomers_numRows + Repeat1__numRows
%>
<%
Dim MM_paramName
%>
<%
' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters

Dim MM_keepNone
Dim MM_keepURL
Dim MM_keepForm
Dim MM_keepBoth

Dim MM_removeList
Dim MM_item
Dim MM_nextItem

' create the list of parameters which should not be maintained
MM_removeList = "&index="
If (MM_paramName <> "") Then
MM_removeList = MM_removeList & "&" & MM_paramName & "="
End If

MM_keepURL=""
MM_keepForm=""
MM_keepBoth=""
MM_keepNone=""

' add the URL parameters to the MM_keepURL string
For Each MM_item In Request.QueryString
MM_nextItem = "&" & MM_item & "="
If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
MM_keepURL = MM_keepURL & MM_nextItem & Server.URLencode(Request.QueryString(MM_item))
End If
Next

' add the Form variables to the MM_keepForm string
For Each MM_item In Request.Form
MM_nextItem = "&" & MM_item & "="
If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
MM_keepForm = MM_keepForm & MM_nextItem & Server.URLencode(Request.Form(MM_item))
End If
Next

' create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL & MM_keepForm
If (MM_keepBoth <> "") Then
MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
End If
If (MM_keepURL <> "") Then
MM_keepURL = Right(MM_keepURL, Len(MM_keepURL) - 1)
End If
If (MM_keepForm <> "") Then
MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)
End If

' a utility function used for adding additional parameters to these strings
Function MM_joinChar(firstItem)
If (firstItem <> "") Then
MM_joinChar = "&"
Else
MM_joinChar = ""
End If
End Function
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Customers</title>
<link href="CSS/Level1_Verdana.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>
</head>

<body>
<table width="815" border="1" cellpadding="1" cellspacing="1">
<tr>
<td width="100"><center><strong>Complaint number </strong></center></td>
<td width="256"><strong>Customer name </strong></td>
<td width="250"><strong>Address</strong></td>
<td width="205"><strong>Telephone number </strong></td>
</tr>
</table>
<div style="border:1px 000000 solid; width: 815px; height: 400px; overflow:auto; ">
<form action="custedit.asp" method="post" name="searchform" id="searchform">
<table width="799" border="1">
<%
While ((Repeat1__numRows <> 0) AND (NOT rsCustomers.EOF))
%>
<tr>
<td width="100"><center>
<%=(rsCustomers.Fields.Item("CustomerID").Value)%>
</center></td>
<td width="256"><a href="javascript:;" onClick="MM_openBrWindow('custinfo.asp?<%=MM_keepNone & MM_joinChar(MM_keepNone)&"CustomerID=" & rsCustomers.Fields.Item("CustomerID").Value%>','','scrollbars=yes,width=400,height=400')"><%=(rsCustomers.Fields.Item("CustomerFullName").Value)%></a> </td>
<td width="252"><% If (rsCustomers.Fields.Item("Address1").Value) <> "" Then %>
<%=(rsCustomers.Fields.Item("Address1").Value)%>
<% Else %>
&nbsp;
<% End If %>
<td width="191"><% If (rsCustomers.Fields.Item("TelNo").Value) <> "" Then %>
<%=(rsCustomers.Fields.Item("TelNo").Value)%>
<% Else %>
&nbsp;
<% End If %>
</td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rsCustomers.MoveNext()
Wend
%>
</table>
</div><p>

<input name="selectname" type="text" id="selectname">
<input type="submit" name="Submit" value="Search">
<input type="reset" name="Reset" value="Reset">
</p>
</form>


<p><a href="summary.asp">Return to summary</a> </p>
</body>
</html>
<%
rsCustomers.Close()
Set rsCustomers = Nothing
%>
 
You have a repeat region but no show region behaviour in the code above

[Peace][Pipe]
 
i've put the show region on the page that customer go's to after searching for the customer name...custedit.asp
 
and you use a go to detail page behaviour above to get to it, therefore you have a problem with your recordset on the custedit page

Cheech

[Peace][Pipe]
 
This is the code for thr recordset on the custedit page!

Dim rsCustomers__MMColParam
rsCustomers__MMColParam = "1"
If (Request.Form("selectname") <> "") Then
rsCustomers__MMColParam = Request.Form("selectname")
End If
%>
<%
Dim rsCustomers
Dim rsCustomers_numRows

Set rsCustomers = Server.CreateObject("ADODB.Recordset")
rsCustomers.ActiveConnection = MM_dbConn_STRING
rsCustomers.Source = "SELECT * FROM tblCustomer WHERE LastName = '" + Replace(rsCustomers__MMColParam, "'", "''") + "'"
rsCustomers.CursorType = 0
rsCustomers.CursorLocation = 2
rsCustomers.LockType = 1
rsCustomers.Open()

rsCustomers_numRows = 0
%>
<html>
 
Sorry I am getting a bit confused as to what you are trying to achieve.

You have one page (Customers) that has a form with links to custinfo page that works.
You also have a form that submits to custedit page. In this you allow the user to type a name or whatever they want and to a search on that. Why not just add edit & info buttons and use them as links removing the form entirely

Cheech

[Peace][Pipe]
 
Cheech,

sorry no wonder you're confused the customers page only links to the custedit page.....sorry
 
Just add another go to detail page behaviour with a different link

[Peace][Pipe]
 
Cheech

i've tried several things with this now and still getting nowhere but what i have noticed is that if i enter a last name that is in the system then the selected record opens but when i enter a name that doesnt exist then i get the error but the error message says requests a current record line 161 & when i look at line 161 in the code it points to firstname not lastname so is this where the problem is?

thanks for all your help
 
The problem is you have no show region if record exists and an alternative for when there is no record. Also why have a search facility when the records are all displayed anyway and all you would need to add is another goto detail page link?

Cheech

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

Part and Inventory Search

Sponsor

Back
Top