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

Recordset Loop 1

Status
Not open for further replies.
Mar 10, 2005
63
US
Hello, I'm having a bit of issues. I'm running a query and then outputing it with the date and title. That part I have working. But sometimes there are more than one item per date and I would like to only list the date once instead of on each record. Here's an example:

05/01/06

-Todays News

04/27/06

-CEO Announcements
-Today's Schedule

04/26/06

- May is Fitness Month

Any help would be appreciated. Thanks.
 
Assuming your recordset is sorted by date such that all row with the same date are adjacent to each other...
[tt]
Dim LastDate

'Prime the pump by getting first date value
LastDate = rs("DateField")

'Loop thru all rows in recordset sorted by date
Do While Not rs.EoF
if LastDate <> rs("DateField") then
'Date changed... make new date line
Response.Write rs("DateField") & "<br>" & vbCrLf
end if

Response.Write " - " & rs("TheOtherField") & "<br>" & vbCrLf

'keep last date before moving to next row
LastDate = rs("DateField")
rs.MoveNext
Loop

rs.Close
set rs = nothing[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top