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

Need to populate the table's columns

Status
Not open for further replies.

sabavno

Programmer
Jul 25, 2002
381
CA
Hi,

I have two recordsets and I need to populate the data from those recordsets into the HTML table.

HTML table should have three columns.

First two columns are populated out of the first recordset:

First Recordset looks like that:

Transit Desktops
100 5
200 3


The third column should be populated from the second recordset.

Second recordset looks like that:

Transit Laptops
100 3
200 1

So the HTML table should finally look like that:

Transit Desktops Laptops
100 5 3
200 3 1


Please suggest how should I loop through those recordsets in order to create the table above.

I'd appreciate your help

THanks.
 
I would actually rewrite the query so that you get one recordset (join the two tables)...
But we'll work with what you've given us....
Code:
DO WHILE NOT objRSDesk.EOF
  thisTransit = objRSDesk("transit")
  DO WHILE NOT objRSlap.EOF
    IF objRSlap("transit") = thisTransit THEN
      strHTML = strHTML & &quot;<tr><td>&quot; & thisTransit & &quot;</td><td>&quot; & objRSdesk(&quot;desktops&quot;) & &quot;</td><td>&quot; & objRSlap(&quot;laptops&quot;) & &quot;</td></tr>&quot;
      EXIT DO
    END IF
    objRSlap.movenext
  LOOP 
  objRSDesk.movenext
LOOP

Not very pretty or efficient, but it will work. This assumes that there is exactly one row for each transit number in each table!!!! (Yikes!) You should probably add some checks to ensure that your data actually fits this &quot;perfect&quot; model....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top