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

checking date through loop...

Status
Not open for further replies.

dodgyone

Technical User
Jan 26, 2001
431
0
0
GB
I'm displaying DB records on screen through the loop command.

There are different dates on screen for one of the fields and I would like to be able to group these in order (that's done... no problem through SQL) but then look at the records and on every group display the date for that group at the top of that table.

So, as it loops check the date and ask whether the previous record date entered is the same or different... if different then display it and carry on displaying the records in that date range until the date changes again and so on. In the end there will be a date, records in tables for that date, a new date and records in tables for that date and so on...

Is this possible/easy to do?
 
When looping, store the previous date in a variable then compare that to the next date. If different, write it out as your group header, if the same then don't:

Dim dtPreviousDate as Date

'loop
do while not end of loop
if rs!Date <> dtPreviousDate then
'write the date

'store the new date
dtPreviousDate = rs!Date
else
'don't write the date - do whatever else

end if

rs.movenext
loop

Hope this helped. -Chris Didion
Matrix Automation, MCP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top