Results 1 to 3 of 3
  1. #1
    George is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Posts
    295

    RecordCount after filtering is incorrect

    Good afternoon,
    The filter output from a recordset in the following code is 1. But this is incorrect: How can this be corrected?


    Private Sub Command43_Click()
    Dim curDatabase As Database
    Set curDatabase = CurrentDb

    Dim rs3 As Recordset
    Dim t As Recordset

    Set rs3 = curDatabase.OpenRecordset("Select * from [Courses under Programs]")



    rs3.Filter = "ProgramCode = 'ANS.CT'"

    Set t = rs3.OpenRecordset

    t.MoveLast
    t.MoveFirst

    MsgBox t.OpenRecordset.RecordCount


    End Sub

  2. #2
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Try changing MsgBox t.OpenRecordset.RecordCount to just

    MsgBox t.RecordCount

    The way you have it, you are re-opening the recordset, which resets the recordcount value.

    John

  3. #3
    George is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Posts
    295
    Thankb you kindly John, you saved me countless hours. I have already wasted many.

    Can you show me how to mark a thread as solved?

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

Similar Threads

  1. Query Data Incorrect
    By Two Gun in forum Queries
    Replies: 8
    Last Post: 01-31-2012, 06:07 PM
  2. Incorrect Sums
    By Azyrus in forum Reports
    Replies: 6
    Last Post: 06-26-2011, 04:27 PM
  3. Recordcount with filter on
    By injanib in forum Forms
    Replies: 3
    Last Post: 06-15-2011, 03:07 PM
  4. Incorrect sorting in report.
    By jonesy29847 in forum Reports
    Replies: 2
    Last Post: 06-16-2010, 05:56 PM
  5. Replies: 3
    Last Post: 10-20-2009, 06:56 AM

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