Results 1 to 5 of 5
  1. #1
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544

    Question rs.FindNext vs. rs.MoveNext

    In an effort to not post a huge list of code I'll keep the code out of it...I posted earlier referring to a "FindNext" function in a recordset. However, if I just "FindNext" along my Do While loop does not advance to .EOF ever. If I use the rs.MoveNext feature (theoretically) will that wipe out my .FindNext command? Should I use .FindNext and then .MoveNext or vice versa?

    What I am trying to do....


    Find only the records that match an employee ID. Once all of the records have been "found" I want to kick out of the Do While loop and exit the function.

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    hello again jg,

    in that last thread, you never mentioned WHAT you do when you 'find' them. hopefully you're doing 'something'?? when I want to loop data like that and find only specific records, I only open the data set with that criteria in the sql statement. At that point, I don't even worry about finding records, because all of them already meet the criteria I want as soon as it's opened.

    could you do that I wonder?? If anything, it'll make your life a whole lot simpler right now.

  3. #3
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    That is a possibility...Let me try to explain a little further...

    I'm building a table to track changes to an employee's information. There can be multiple instances of the same employee. Specifically I am checking of their Position, Location or Pay Type changed. If either of those changed then I want to append the data from my current employee table to that "archive" table. So I want to find the first instance of the employee record, check to see if those criteria have changed, if anything has changed I append the record to the table and if nothing has changed I want to move on to the next employee. So I do not think just running a query on the recordset will solve my problem. If you can think of a simpler method for this I am all ears/eyes, believe me!

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    your situation still applies. what I meant was something like:

    Code:
    dim rs as dao.recordset
    set rs = currentdb.openrecordset("select * from table where employeeid = 5")
    
    rs.movelast
    rs.movefirst
    
    with rs
       while not .eof
          inequality condition here (then)
             'append the record or run sql comm..
          end if
                .movenext
       wend
    end with
    
    etc, etc...
    make sense??

  5. #5
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Yes that does. I'll give it a shot.

Please reply to this thread with any new information or opinions.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums