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

Repeat region

Status
Not open for further replies.

redbay

Technical User
Oct 13, 2003
145
GB
Hi, i have my recordset set up and working OK but as soon as i put a repeat region on it i get either BOF or EOF is Trues, requires a current record....can anyone tell me where i am going wrong?
 
can anyone tell me where i am going wrong
Yes you need to give us more information, can you output a single record to the page? Post the code for the page so we can have a look

[Peace][Pipe]
 
Yes it works fine with a single record, i have an update record on the form and when i take that off it also works fine, here's the code

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/dbConn.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_dbConn_STRING
MM_editTable = "tblCustomer"
MM_editColumn = "CustomerID"
MM_recordId = "" + Request.Form("MM_recordId") + ""
MM_editRedirectUrl = "test.asp"
MM_fieldsStr = "checkbox|value"
MM_columnsStr = "Status|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 rsT__MMColParam
rsT__MMColParam = "1"
If (Request.QueryString("CustomerID") <> "") Then
rsT__MMColParam = Request.QueryString("CustomerID")
End If
%>
<%
Dim rsT
Dim rsT_numRows

Set rsT = Server.CreateObject("ADODB.Recordset")
rsT.ActiveConnection = MM_dbConn_STRING
rsT.Source = "SELECT * FROM qryActDet WHERE CustomerID = " + Replace(rsT__MMColParam, "'", "''") + ""
rsT.CursorType = 0
rsT.CursorLocation = 2
rsT.LockType = 1
rsT.Open()

rsT_numRows = 0
%>
<%
Dim rsTest
Dim rsTest_numRows

Set rsTest = Server.CreateObject("ADODB.Recordset")
rsTest.ActiveConnection = MM_dbConn_STRING
rsTest.Source = "SELECT * FROM tblCustomer"
rsTest.CursorType = 0
rsTest.CursorLocation = 2
rsTest.LockType = 1
rsTest.Open()

rsTest_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = 10
Repeat1__index = 0
rsT_numRows = rsT_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>Customer actions</title>
<link href="CSS/Level1_Verdana.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {font-size: 120%}
-->
</style>
</head>

<body>
<h1>Customer actions</h1>
<h3><%=(rsT.Fields.Item("CustomerFullName").Value)%> </h3>
<form name="form5" method="post" action="">
<table width="500" border="0" cellpadding="0" cellspacing="0" id="Toptable">
<tr>
<td><div align="right">Complaint number:</div></td>
<td><%=(rsT.Fields.Item("ComplaintID").Value)%> - <%=(rsT.Fields.Item("CustomerID").Value)%></td>
</tr>
<tr>
<td><div align="right">Complaint date:</div></td>
<td><input name="textfield" type="text" value="<%=(rsT.Fields.Item("ComplaintDate").Value)%>"></td>
</tr>
<tr>
<td><div align="right">Category:</div></td>
<td><input name="textfield" type="text" value="<%=(rsT.Fields.Item("Category").Value)%>"></td>
</tr>
</table>
</form>
<hr>
<br>
<table width="1100" border="1" cellpadding="1" cellspacing="1" id="Midtable">
<tr>
<td width="120"><center>Date received </center></td>
<td width="120"><center>Acknowledged</center></td>
<td width="160"><center>Date acknowledged </center></td>
<td width="200"><center>By whom </center></td>
<td width="160"><center>Closure due by </center></td>
<td width="130"><center>Action closed </center></td>
<td width="80"><center>Pass to other </center></td>
<td width="110">&nbsp;</td>
</tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT rsT.EOF))
%>
<tr>
<td><%=(rsT.Fields.Item("DateReceived").Value)%></td>
<td><center>
<div align="center">
<input <%If (CStr((rsT.Fields.Item("InitialResponse").Value)) = CStr("True")) Then Response.Write("checked") : Response.Write("")%> type="checkbox" name="checkbox" value="checkbox">
</centre></div></td>
<td><%=(rsT.Fields.Item("DateInitialResponse").Value)%></td>
<td><%=(rsT.Fields.Item("AcknowledgedBy").Value)%></td>
<td><%=(rsT.Fields.Item("ClosureDueBy").Value)%></td>
<td>
<div align="center">
<input <%If (CStr((rsT.Fields.Item("ActionClosed").Value)) = CStr("True")) Then Response.Write("checked") : Response.Write("")%> type="checkbox" name="checkbox" value="checkbox">
</div></td>
<td><% If(rsT.Fields.Item("PassToOther").Value) = True Then%>
<center>
Yes
</center> <% Else%>
<center>
No
</center> <%End If %>
</td>
<td><A HREF="actedit.asp?<%= Server.HTMLEncode(MM_keepNone) & MM_joinChar(MM_keepNone) & "ActionID=" & rsT.Fields.Item("ActionID").Value %>">Full Details</A> </td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rsT.MoveNext()
Wend
%>

</table>
<form name="form1" method="POST" action="<%=MM_editAction%>">
<input type="checkbox" name="checkbox" value="checkbox">
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="MM_recordId" value="<%= rsT.Fields.Item("CustomerID").Value %>">
</form>
<p>&nbsp;</p>
</body>
</html>
<%
rsT.Close()
Set rsT = Nothing
%>
<%
rsTest.Close()
Set rsTest = Nothing
%>
 
The form you have at the bottom of the page
Code:
<form name="form1" method="POST" action="<%=MM_editAction%>">
  <input type="checkbox" name="checkbox" value="checkbox">
  <input type="hidden" name="MM_update" value="form1">
  <input type="hidden" name="MM_recordId" value="<%= rsT.Fields.Item("CustomerID").Value %>">
</form>

has a hidden field set to rsT.Fields.Item("CustomerID").Value Having just used a repaet region to go through all of the records you are now at the eof I guess that the update form needs to be moved into the repeat region.

Cheech

[Peace][Pipe]
 
Thanks Cheech. Ive inserted a new column at the end of the repeat region and inserted the update form this works OK except that the update form is now on every row, how can i make it only appear the once?
 
have tried that but cant get it to do what i want....could i not create a layer and have its visibility set to true if more than one record displayed?
 
Yes you could but what would that achieve? If you need to have multiple records updated at once then you need to do something similar to the above link. You could use some logic that displayed links to update each record individually if there was more than one record, but I guess that detracts from the problem.

Cheech

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

Part and Inventory Search

Sponsor

Back
Top