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

counting in a recordset for asp

Status
Not open for further replies.

storm1976

Programmer
Jul 6, 2001
31
GB
hi there,

just asking for a bit of advice really.

i have got a recordset and would like to look through it counting through the number of times a status comes up. the status at the moment is a range of 0-4 but this could be changed.

for each number of the range i would like to count the recordset for each appearance and give out the final value.

i did at first use a select case function but it was hard coded rather than dynamic so could not be added to in the future.

have been told to look at recursive programming to create a function but not sure which way to go round it.

hope there are people out there who have got some ideas (and also some who have actually understood what ive been waffling about)

cheers in advance
Storm1976
 
You could create a 2 dimensional array which could grow as your status gets bigger.

You can ReDim Preserve array(x,y) inside your recordset loop when a new (higher) status is encountered.

Hope this makes sense.

BDC.

P.S. this thread should really be in the ASP forum forum333 ;-)
 
Here's how I've done this (off the top of my head).

Got a recordset of statuses.

Created an 2dim-array. 1st stores the status id.

Then get a recordset of data (rsData).

cycle through the status array
and reset filter to rsData
rsData.filter = "status = " & arrStatus(i,0)

Then cycle through rsData and assign count to 2nd dim in array.
arrStatus(i,1) = arrStatus(i,1) + 1


finally cycle through status array once more outputting id & count.

HTH, Jessica [ponytails2]
 
Jessica FYI Storm has also posted in the ASP forum thread333-473336 ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top