Results 1 to 15 of 15
  1. #1
    jctaylor is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    16

    Find.first in recordset

    I have two recordsets and I am trying to loop through the first and find the record in the second with the same invoice number, but it keeps taking me to the first record in the second recordset instead.



    PartialCode

    Set rst = CurrentDb.OpenRecordset(StrSql)
    Set rst1 = CurrentDb.OpenRecordset("AR")
    rst.MoveFirst

    Do While Not rst.EOF
    With rst1
    .FindFirst "[rst1!inv_no]= '" & [rst!invno] & "' "
    If rst1.NoMatch Then
    MsgBox "Record not found"
    Exit Sub
    End If
    MsgBox rst1!client & " " & rst1!inv_no & " " & rst1!inv_date
    End With
    rst.MoveNext

    Loop

    rst.Close
    rst1.Close
    Set rst = Nothing
    Set rst1 = Nothing

    /Code

    I am not sure what I am doing wrong. I have tried several things but nothing works. Any help in leading me in the right direction would be appreciated.

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Is the invoice number numeric or text datatype?

  3. #3
    jctaylor is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    16
    Invoice number is text

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Try

    .FindFirst "[inv_no]= '" & rst!invno & "'"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    jctaylor is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    16
    It still brings up the first record. Why doesn't my nomatch work since it didn't find what I was looking for?

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Can you attach the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    jctaylor is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    16
    How do I do that?

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Compact/repair, then zip, then attach in the Go Advanced area.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    jctaylor is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    16
    It doesn't like my zipfile that I keep trying to upload.

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Is it under the 2mb limit?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    jctaylor is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    16
    No, it's greater than 2mb.

  12. #12
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Can you cut it down to just the objects required to recreate this problem (by exporting to a new db)? If not, you can email it to me.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Don't use [ ] around the record set reference in the FindFirst expression. Oh, I see Paul already caught that.

    Maybe make a copy and delete data. Be sure to run compact and repair before zipping.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  14. #14
    jctaylor is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    16
    I finally got it to work. I had ' " reversed!! Thanks for your help.

  15. #15
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Glad you got it sorted.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 6
    Last Post: 12-03-2013, 11:14 PM
  2. How to Select second Recordset from first recordset
    By FrustratedAlso in forum Programming
    Replies: 28
    Last Post: 05-10-2012, 05:45 PM
  3. Replies: 2
    Last Post: 03-08-2012, 12:59 PM
  4. Using a recordset to find ANY records
    By Drak in forum Programming
    Replies: 7
    Last Post: 01-10-2012, 07:11 PM
  5. Replies: 1
    Last Post: 11-13-2009, 03:03 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