Results 1 to 4 of 4
  1. #1
    ManuelLavesa is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Posts
    113

    Making a recordset with a query


    Hello I am trying to make a recordset with a query my code is as follows
    Code:
     
    Public Sub OpenInvoices()
    Dim db as DAO.Database
    Dim rs As DAO.Recordset
    
    Set db = CurrentDb ()
    Set rs = db.OpenRecordset ("QryOpenInvoices")
    
    With rs
    Debug.Print .Recordcount
    .Close
    End With
    
    Set rs = Nothing
    Set db = Nothing
    
    End Sub
    The Problem I am having is that when I run the query I have 32 records, but when I run this recordset I only get a recordcount of 1. I don't know what I am doing wrong any help will be greatly appreciated. Thank you

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    You can't trust the record count until you access the entire recordset:

    http://www.baldyweb.com/RecordCounts.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ManuelLavesa is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Posts
    113
    Hello Pbaldy, thank you for your help.. you solved my problem now I get the 32 records and I learned a good lesson.

  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,518
    Happy to help!
    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. Making a Recordset trouble
    By NightWalker in forum Programming
    Replies: 30
    Last Post: 12-23-2016, 05:00 PM
  2. Replies: 8
    Last Post: 08-14-2014, 06:00 AM
  3. Need help with making a Query
    By Troop in forum Access
    Replies: 3
    Last Post: 04-22-2013, 08:46 AM
  4. Replies: 2
    Last Post: 03-08-2012, 12:59 PM
  5. making a query
    By macattack03 in forum Access
    Replies: 2
    Last Post: 04-23-2011, 12:00 PM

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