472,126 Members | 1,523 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,126 software developers and data experts.

Duplicate value in ASP. How to group it.

Hi all,
I have a join query in asp (using access) with ouput like this:

Name Grd Math English
Jon 1 7.0 7.5
Jon 2 8.0 7.0
Ana 1 6.5 8.0
Ana 2 6.0 8.5

Is it possible to hide the duplicate name (jon & ana)?
I want the ouput like this:

Name Grd Math English
Jon 1 7.0 7.5
2 8.0 7.0
Ana 1 6.5 8.0
2 6.0 8.5


Thanks,
aaronzz
Mar 19 '07 #1
1 951
jhardman
3,406 Expert 2GB
Hi all,
I have a join query in asp (using access) with ouput like this:

Name Grd Math English
Jon 1 7.0 7.5
Jon 2 8.0 7.0
Ana 1 6.5 8.0
Ana 2 6.0 8.5

Is it possible to hide the duplicate name (jon & ana)?
I want the ouput like this:

Name Grd Math English
Jon 1 7.0 7.5
2 8.0 7.0
Ana 1 6.5 8.0
2 6.0 8.5


Thanks,
aaronzz
Easiest way I have found requires that I state very carefully what I print at each line:
Expand|Select|Wrap|Line Numbers
  1. <table><tr>
  2. <%
  3. for each fld in objRS.fields %>
  4.    <td><%=fld.name%></td>
  5. <%
  6. next %>
  7. </tr>
  8. <tr>
  9. <%
  10. for each fld in objRS.fields %>
  11.    <td><%=fld.value%></td>
  12. <%
  13. next %>
  14. </tr>
  15. <%
  16. lastName = objRS("NAME")
  17. objRS.moveNext
  18. do while not objRS.eof %>
  19.    <tr>
  20.    <%
  21.    for each fld in objRS.fields
  22.       if fld.name = "NAME" AND fld.value = lastName then %>
  23.          <td></td>
  24.       <%
  25.       else %>
  26.          <td><%=fld.value%></td>
  27.       <%
  28.       end if
  29.    next %>
  30.    </tr>
  31.    <%
  32.    lastName = objRS("NAME")
  33.    objRS.moveNext
  34. loop %>
  35. </table>
I can't think of an easier way to do it. First I pull up the name of each field and put them across the top of a table. Then I pull up the first entry (because you will want the first entry to show in its entirety regardless) and display it in the second row of the table. Then i set a variable with the current NAME record before I move to the next. The I do a regular do...loop which posts each line of the database to the table, but each field is checked. If the field name is "NAME" and the value is the same as the previous name, I write a blank table cell, otherwise it prints the value to the table. Then, right before I move to the next record, I update the lastName variable.

Does this help?

Jared
Mar 20 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by Lowell Kirsh | last post: by
3 posts views Thread by andreas.maurer1971 | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.