dividing a recordset up for display?

E

eyoung

I placed some code below...took out most of the unneeded html crap for
this.
this gives me a listing of phone charges...every other line with a
different color for easy reading.
What I want is this with all entries for the first "Service Number"
then a space then everything for the next "Service Number" on and on
until the end. Can someone tell me how to do this?

<table>
<tr>
<td>Service Number</td>
<td>Subscriber</td>
<td>Description</td>
<td>To Number</td>
<td><div><b>Duration </td>
<td>Connect Date</td>
<td>Amount</td>
</tr>

<%
Dim sBackgroundColor
sBackgroundColor = "#ffffff"

Do until rs.eof

If rs("Service Number") <> "" Then
If sBackgroundColor = "#ffffff" Then
sBackgroundColor = "#f7f7f7"
Else
sBackgroundColor = "#ffffff"
End If
%>

<tr bgcolor="<%=sBackgroundColor%>">
<td><%=rs("Service Number")%></td>
<td><%=rs("Subscriber User Name")%></td>
<td><%=rs("Description")%></td>
<td><%=rs("To Number")%></td>
<td align="center"><%=rs("Duration")%></td>
<td><%=rs("Connect Date")%></td>
<td align="right"><%=rs("Total Charge")%></td>
</tr>

<% End If
rs.MoveNext
Loop %>
</table>
 
R

Ray Costanzo [MVP]

Can you reword the quoted part below? I tried, but I don't really
understand what you're trying to do here.

Ray at work
 
E

eyoung

Yes, what I have gives me every entry for 555-1111 then every entry for
555-1112 then 555-1113 in one big table...this because my query sorted
on "Service Number" which is the telephone number. One big recordset.

I think I want some kind of loop to run threw this and get all the
entries for 555-1111 then a space...then the next time threw the loop I
get everything for the next number.
I want to do some calculations but I won't have a problem with that if
I get the loop
 
E

eyoung

I'm not looking for someone to write script for me...I just need to
know what to do.

I'm guessing I need a for each loop here.
But how do I go about that...I've looked at some web samples but they
don't trigger anything in my super human intelligent brain :)
 
R

Ray Costanzo [MVP]

So, you're saying that you get:

555-1111 data data data
555-1111 data data data
555-1111 data data data
555-1111 data data data
555-1112 data data data
555-1112 data data data
555-1112 data data data


But what you want is:
555-1111 data data data
data data data
data data data
data data data
555-1112 data data data
data data data
data data data

If so, here's an option: http://www.aspfaq.com/show.asp?id=2241 Be sure to
read the whole page and not just grab the first code sample!

Ray at work
 
L

ljb

Ray Costanzo said:
So, you're saying that you get:

555-1111 data data data
555-1111 data data data
555-1111 data data data
555-1111 data data data
555-1112 data data data
555-1112 data data data
555-1112 data data data


But what you want is:
555-1111 data data data
data data data
data data data
data data data
555-1112 data data data
data data data
data data data

If so, here's an option: http://www.aspfaq.com/show.asp?id=2241 Be sure to
read the whole page and not just grab the first code sample!

Ray at work

My preference for doing this is to dump the entire record set into an array
with myarray = rs.getrows. That way I don't have to keep previous row values
in variables and check if they changed. All I do is check the current column
and row against the value on
if myarray(CurCol, CurRow) <> myarray(CurCol, CurRow -1) then...
 
G

Griff

If using classic ADO, you could also consider using a hierarchical (shaped)
recordset
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top