Avatar of NJPhillips
 asked on

Add data from recordset to array and sort by date

I have a recordset, "rsTaskinfo" which has a field titled "StatusDateTime" which lists the date/time stamp a person updated their status. What I would like to do is find the last entry entry.... the kicker, is the recordset is already sorted by a persons name, otherwise it would be easy.

My thoughts were to add all of the records to an array and sort that way... but I am not sure if that is very efficient.

What say you experts?

Avatar of undefined
Last Comment
Scott Fell

8/22/2022 - Mon
Scott Fell

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Your solution is do-able, and was my first thought... I was just hoping to minimize trips to the DB is possible... however, it might really be more efficient to do that.

Scott Fell

There is a more efficient way as far as the database to throw it into an array but the trade off is a little more complex code.  

Do you have 100,000's rows in the database?  Do you have 100's of people per minute accessing database? Does the query contain a lot of wild card searches?    I think what is "better" is personal preference and use.  If the actual usage is small, I think it is easier to go with the simple code.  

Without knowing what datafields you need it is hard to give you that option.  In short, you would create a dynamic array.

' open rs
    Dim demoArray()
    Dim counter
     counter = 0
    do until rs.eof
        ReDim Preserve demoArray(i)
        DemoArray(counter) = rs.field
       if not rs.eof then
          counter = counter +1
      end if
'close rs
' now that you have your array, create a function to check the array with each row of data in your display

Function  functionName( checkID)
      matchID = 0
     for each x in demoArray
         if x = checkID then
            macthID = checkID
        end if
end function
' the returned matchID can then be used to mark the record with the last update
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck