• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 593
  • Last Modified:

Classic ASP VBScript: How to add a blank row after every 5 records in a Repeat Region

Classic ASP VBScript
MS Access
WIN XP PRO
DW MX

Hello.  I have a DW Repeat Region on a row <TR> of a table.  I would like to be able to add an empty row after every 5 records that are listed; however, I'm not sure how to do that.

Is this possible?  If so... how could I do this?


Thanks so much,
Shane
0
lshane
Asked:
lshane
  • 3
  • 3
1 Solution
 
slamhoundCommented:
Can you post the relevant code please?
0
 
lshaneAuthor Commented:
Hi, slamhound.  Thank you.  Yes, I just created a quick test page listing the products and their type/status.  It's just, I would like (or my admins) are requesting a blank row after every 5 listed records.  I would imagine a "Count" of some sort would have to be implemented, but I have very little of a clue how.  I am using the DWMX Repeat Region behavior.  

Here's the code:
====================================================================
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/connPMDData2_DSN.asp" -->
<%
Dim rsCParts
Dim rsCParts_numRows

Set rsCParts = Server.CreateObject("ADODB.Recordset")
rsCParts.ActiveConnection = MM_connPMDData2_DSN_STRING
rsCParts.Source = "SELECT * FROM common_parts ORDER BY cp_ID ASC"
rsCParts.CursorType = 0
rsCParts.CursorLocation = 2
rsCParts.LockType = 1
rsCParts.Open()

rsCParts_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
rsCParts_numRows = rsCParts_numRows + Repeat1__numRows
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<table width="500" border="0" cellspacing="0" cellpadding="0">
  <%
While ((Repeat1__numRows <> 0) AND (NOT rsCParts.EOF))
%>
  <tr>
    <td width="200"><%=(rsCParts.Fields.Item("cp_ID").Value)%></td>
    <td width="300"><%=(rsCParts.Fields.Item("cp_Status").Value)%></td>
  </tr>
  <%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  rsCParts.MoveNext()
Wend
%>
</table>
</body>
</html>
<%
rsCParts.Close()
Set rsCParts = Nothing
%>
====================================================================

Thanks so much,
Shane
0
 
slamhoundCommented:
Something like this should work for you:
  <%
LineCount = 0
While ((Repeat1__numRows <> 0) AND (NOT rsCParts.EOF))
%>
  <tr>
    <td width="200"><%=(rsCParts.Fields.Item("cp_ID").Value)%></td>
    <td width="300"><%=(rsCParts.Fields.Item("cp_Status").Value)%></td>
  </tr>
  <%
LineCount = LineCount + 1
if LineCount = 5 then ' 5th row printed
%>
<tr><td colspan=9> </td></tr>
<%
LineCount = 0 ' Reset the count back to zero again for the next blank line
end if
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  rsCParts.MoveNext()
Wend
%>
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
lshaneAuthor Commented:
Hi, slamhound.  Well, I tried it, but I stil just have a basic repeating region list.  It does not appear to have placed the additional row.

I am at home now, so I had to make another test page, and therefore, have a different recordset name.  I modified your suggestion to it, but still have the same result.

Here's the code now (With yours):

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/connPMDData2_DSN.asp" -->
<%
Dim rsTest
Dim rsTest_numRows

Set rsTest = Server.CreateObject("ADODB.Recordset")
rsTest.ActiveConnection = MM_connPMDData2_DSN_STRING
rsTest.Source = "SELECT * FROM supplies ORDER BY suppID ASC"
rsTest.CursorType = 0
rsTest.CursorLocation = 2
rsTest.LockType = 1
rsTest.Open()

rsTest_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
rsTest_numRows = rsTest_numRows + Repeat1__numRows
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<table width="700" border="0" cellspacing="0" cellpadding="0">
<%
LineCount = 0
While ((Repeat1__numRows <> 0) AND (NOT rsTest.EOF))
%>
  <tr>
    <td width="100"><%=(rsTest.Fields.Item("suppID").Value)%></td>
    <td width="600"><%=(rsTest.Fields.Item("suppName").Value)%></td>
  </tr>
  <%
LineCount = LineCount + 1
if LineCount = 5 then ' 5th row printed
%>
<tr><td colspan=9> </td></tr>
<%
LineCount = 0 ' Reset the count back to zero again for the next blank line
end if
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  rsTest.MoveNext()
Wend
%>

</table>
</body>
</html>
<%
rsTest.Close()
Set rsTest = Nothing
%>



Thanks so much,
Shane
0
 
slamhoundCommented:
Try replacing this:
%>
<tr><td colspan=9> </td></tr>
<%
With this:
%>
<tr><td colspan=2><hr></td></tr>
<%

and let me know what you see.
0
 
lshaneAuthor Commented:
Awesome!  Thank you!


Shane
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now