To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
Part 10 of the Visual Basic .NET 2010 Express Tutorial Complete!
How to Use the Visual Studio Code Analysis Tool FxCop
Article :: Interview with Andrei Alexandrescu (Part 3 of 3)
Introducing Visual Studio LightSwitch
Visual Studio LightSwitch Beta 1 is Available



Go Back   VBForums > Visual Basic > ASP, VB Script

Reply Post New Thread
 
Thread Tools Display Modes
Old Apr 20th, 2006, 11:50 PM   #1
azrina
Lively Member
 
Join Date: Jan 04
Posts: 100
azrina is an unknown quantity at this point (<10)
Loop Problem

I am having problem with my loop.
Referring to the table.jpg, the row repeats with the same data for column Nama and ID.
Do you have any idea how can I group the data so that there wont be any repeatition.
Thanks in advance.

Below is the portion of my code.
VB Code:
  1. set gStaf = server.CreateObject("adodb.recordset")
  2.                 gStaf.open "SELECT * FROM staf " ,conn
  3.                
  4.                 k=0
  5.                 for i=1 to gstaf.recordcount
  6.                
  7.                    
  8.                     set gPermohonan = server.CreateObject("adodb.recordset")
  9.                     gPermohonan.open "SELECT * FROM permohonan WHERE jpk=2 AND uid="&gStaf("id")&" " ,conn
  10.                    
  11.                    
  12.                     if not gStaf.eof then
  13.                                                
  14.                         for j=1 to gPermohonan.recordcount
  15.                         k=k+1
  16.             %>
  17.                         <tr class="bgcontent">
  18.                     <td><%=k%></td>
  19.                     <td><%=gStaf("bno")%></td>
  20.                     <td><%=gStaf("nama")%></td>
  21.                     <td>
  22.                             <%
  23.                                 set mc = server.CreateObject("adodb.recordset")
  24.                                 mc.open "SELECT * FROM permohonan WHERE jpk=2 AND uid="&gStaf("id")&" AND tarikhmula >= #"&request.Form("tarikhmula")&"# AND tarikhmula <= #"&request.form("tarikhtamat")&"# ",conn
  25.                                
  26.                                 if not mc.eof then
  27.                                     for x=1 to mc.recordcount
  28.                                         tarikhM = mc("tarikhmula")
  29.                                         tarikhT = mc("tarikhtamat")
  30.                                         uid = mc("uid")
  31.                                        
  32.                                     'untuk first record
  33.                                     if x=1 then
  34.                                         response.Write(tarikhM &" - "& tarikhT)
  35.                                         response.Write("<br>")
  36.                                     end if
  37.                                    
  38.                                     'untuk record yg seterusnya..pegi kat previous record
  39.                                     'sbb nak amek nilai uid masuk kat variable userID..rationally tgk kat if kat bawah
  40.                                     if x>=2 then
  41.                                         mc.moveprevious
  42.                                         userID = mc("uid")
  43.                                         mc.movenext
  44.                                    
  45.                                     'pas tuh compare userID yg previous record ngn uid current record
  46.                                     'kalo tak sama baru break
  47.                                     if uid = userID then
  48.                                         response.write(tarikhM &"-"& tarikhT)   
  49.                                         response.Write("<br>")               
  50.                                     end if
  51.                                    
  52.                                    
  53.                                 end if
  54.                                 'end if
  55.                             %>
  56.                            
  57.                             <%
  58.                                 mc.movenext
  59.                                 next
  60.                                 end if
  61.                             %>
  62.                         </td>
  63.                     <td>&nbsp;</td>
  64.                     <td>&nbsp;</td>
  65.                     <td>&nbsp;</td>
  66.                   </tr>
  67.                        
  68.                 <%
  69.                     gPermohonan.movenext
  70.                     next
  71.                     end if
  72.                     gStaf.movenext
  73.                     next
  74.                 %>
Attached Images
 
azrina is offline   Reply With Quote
Reply

Go Back   VBForums > Visual Basic > ASP, VB Script


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:03 AM.





Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.