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

How To Repeat Header Every 10 Rows? 2

Status
Not open for further replies.

snowyej

Technical User
Nov 26, 2001
69
US
Ok, I think I have this pretty much figured out, but I'm getting the following error:

ADODB.Field error '800a0bcd'
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.


Basically, in the table I've created to pull data from my database (Access) I want the header row to repeat every 10 rows.

Here's the basic code that I have for the table:

Do While NOT oRS.EOF

i=0

Response.Write(...header column 1...)
Response.Write(...header column 2...)
etc..

Do Until i=10

i=i+1

Response.Write(...data column 1...)
Response.Write(...data column 1...)
etc...

oRS.MoveNext

Loop

Loop


When I view the page in a browser, it looks like it should except that after the header + 10 rows it shows the above error and then continues with the header and 11th-20th rows.

I'm sure there is a very simple answer, but being that I'm very new at this, I can't figure it out. Any help is greatly appreciated!

Elizabeth :)
 
hi,
try this code....

Do While NOT oRS.EOF

i=0

Response.Write(...header column 1...)
Response.Write(...header column 2...)
etc..

for i = 1 to 10


Response.Write(...data column 1...)
Response.Write(...data column 1...)
etc...


next

oRS.MoveNext

Loop

Sunil
 
Tried that and it showed the header and then the first record 10 times; showed the header and then the second record 10 times; etc...

So I thought maybe I'd try to swap "Next" and "oRS.MoveNext", but that gave me the same error I was getting before.

Any other suggestions?

Thanks!!
Elizabeth :)
 
Maybe try posting some more code. That looks like it would work, let me see it with all the details.

Also, are you sure you don't mean "data RECORD 1"? -Phil
fillup07@hotmail.com
 
Hi,

i think this is what u r looking for.... I am assumming that every for 10 records printed
u want to print the Header

Response.Write(...header column 1...)
Response.Write(...header column 2...)
etc..
i = 0

Do While NOT oRS.EOF

if i= 10 then

Response.Write(...header column 1...)
Response.Write(...header column 2...)
etc..
i = 0
end if



Response.Write(...data column 1...)
Response.Write(...data column 1...)
etc...

i = i +1
oRS.MoveNext

Loop

Sunil
 
Phil,

Oops! Yes, I meant data Record 1. My bad.. Since this table is fairly large, I'll just fill in some of the fields from record:

<%
Option Explicit
Response.Expires = -1000

Dim oConn
Dim oRS
Dim sSQL
Dim sEmail
Dim sWebsite
Dim i

Set oConn = Server.CreateObject(&quot;ADODB.Connection&quot;)
oConn.Open(&quot;DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=&quot; & Server.MapPath(&quot;db\dodger.mdb&quot;))

sSQL = &quot;SELECT ID, Name, Email, Website FROM tblMain ORDER BY ID
Set oRS = oConn.Execute(sSQL)

Do While NOT oRS.EOF

i=0

Response.Write(&quot;<table border=1 cellpadding=3 cellspacing=1 style='font-family:arial; font-size:10pt;'>&quot;)
Response.Write(&quot;<tr bgcolor=darkblue style='color:white; font-weight:bold'><td align=center>ID</td>&quot;)
Response.Write(&quot;<td align=center>Name</td>&quot;)
Response.Write(&quot;<td align=center>Website</td>&quot;)

For i = 1 To 10

sEmail = oRS(&quot;EmailAddress&quot;).Value
If sEmail <> &quot;&quot; Then
sEmail = &quot;<a href=mailto:&quot; & oRS (&quot;EmailAddress&quot;).Value & &quot;>&quot; & oRS(&quot;Name&quot;).Value & &quot;</a>&quot;
Else
sEmail = oRS(&quot;OwnerName&quot;).Value
End If

sWebsite = oRS(&quot;Website&quot;).Value
If sWebsite <> &quot;&quot; Then
sWebsite = &quot;<a href=&quot; & oRS(&quot;Website&quot;).Value & &quot; target=_blank>&quot; & &quot;Webpage&quot; & &quot;</a>&quot;
Else
sWebsite = &quot;&quot;
End If

Response.Write(&quot;<td align=center>&quot; & oRS(&quot;ID&quot;).Value & &quot;</td>&quot;)
Response.Write(&quot;<td align=center>&quot; & sEmail & &quot;</td>&quot;)
Response.Write(&quot;<td align=center>&quot; & sWebsite & &quot;</td></tr>&quot;)

sEmail = &quot;&quot;
sWebsite = &quot;&quot;

Next

oRS.MoveNext

Loop

Response.Write(&quot;</table><br><br>&quot;)

oConn.Close
Set oRS = Nothing
Set oConn = Nothing

%>


There ya go... Hopefully it got copied/pasted right.

Elizabeth :)
 
Sunil,

That worked! One more question though... My table cells are not a fixed size so depending on how long the words are in the cell determines how wide that column is. After it put the second header, the columns starting with the 2nd header on down are not the same width as the columns above.

Here's the page I'm working on so that you can see what I mean:
Is there a way to fix this?

Thanks for all your help!

Elizabeth :)
 
Move the
Response.write(&quot;<table...&quot;)

to above the
Do While Not...

Right now you are creating a new table without closing the first one.
 
That did it! So simple. I should've figured that out!

Thanks Juanita!

Elizabeth :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top