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

    Question Research sources

    I'm looking for a good website/websites that can explain the Recordset functions and how they work. Currently I'm wanting to understand the .FindNext function and how it works. I was under the impression it would find the next instance of the "filter" you gave it, and stop once it had found all of the instances. However, mine appears to just loop back to the top. Here is my code...



    Code:
    Set db = CurrentDb
    Set rs = db.OpenRecordset("tblAudit", dbOpenDynaset)
    
    rs.FindFirst "[A$EMPLOYEE_NUMBER] = " & emplID
    
    Do While Not rs.EOF
        vPosition = rs("JOB_NAME")
        vPositionDate = rs("DOWNLOAD_DT")
        
        If vPositionDate < vCurrPositionDate Then
            If vPosition <> vCurrPosition Then
                'Do whatever necessary
            End If
        End If
        
        rs.FindNext "[A$EMPLOYEE_NUMBER] = " & emplID
        Loop

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    15,730

  3. #3
    ajetrumpet is offline Banned
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    are you sure that's what it's doing??

    the one thing I notice is that you're not opening the recordset, thus your should only have 1 record in it. perhaps that's the reason for the apparent loop?

    a truely unique google search.

  4. #4
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Not opening the recordset? Do enlighten me on this one. I was under the impression using the:

    Code:
    Set rs = db.OpenRecordset("tblAudit", dbOpenDynaset)
    was doing just that...

  5. #5
    ajetrumpet is offline Banned
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    for some reason, that only opens the first rec. you always need:
    Code:
    rs.movelast
    rs.movefirst
    don't ask me why.

  6. #6
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    hahaha, awesome. Thanks!

  7. #7
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    So just to re-cap...

    Using my code above (With the exception of adding the glorious rs.movelast, rs.movefirst) should find the first instance of emplID and the find each instance after that until it reaches the end/bottom. It should not jump back up to top and start again. Correct?

  8. #8
    ajetrumpet is offline Banned
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by jgelpi16 View Post
    So just to re-cap...

    Using my code above (With the exception of adding the glorious rs.movelast, rs.movefirst) should find the first instance of emplID and the find each instance after that until it reaches the end/bottom. It should not jump back up to top and start again. Correct?
    I'm not sure about that, jg. I assume that it doesn't jump back to the front because that makes logical sense, but this is microsoft technology, so you never know.

    I can't tell you. never tried it. it'll be up to you to test.

    the best for this type of thing though is to let it run and put:
    Code:
    debug.print rs.absoluteposition
    inside the conditional in the loop. the immediate window will "immediately" tell you if you're gonna see numbers more than once in a single run.

  9. #9
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Wait....Are you suggesting that Microsoft would develop something that doesn't make complete and total logical sense?....I don't believe it. :-p.

    Thanks for that little tip! Learn something new every day....So they say.

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

Similar Threads

  1. Manipulating Form&Query Sources
    By dinorbaccess in forum Forms
    Replies: 3
    Last Post: 12-30-2010, 11:11 AM
  2. Query involving data from different sources
    By nodnud in forum Queries
    Replies: 1
    Last Post: 08-12-2010, 06:11 PM
  3. Link to multiple sources
    By AquaChaos in forum Import/Export Data
    Replies: 4
    Last Post: 06-16-2010, 02:43 PM
  4. Cross check data from 2 sources
    By Zukster in forum Queries
    Replies: 7
    Last Post: 09-22-2009, 10:54 AM
  5. 2 SQL Database sources one frontend
    By kevinharding in forum Programming
    Replies: 3
    Last Post: 03-22-2006, 06:34 AM

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