Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9231451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:04:19+00:00 2026-06-18T06:04:19+00:00

I am using an Access2010 project as frontend, referring to a MS SQL Server

  • 0

I am using an Access2010 project as frontend, referring to a MS SQL Server 2008 as backend. Within my Access project there is form frmKlientenÜbersicht. This form has a view abfKlientenÜbersicht as dataSource.

Now I am trying to get the current number of records showing up in my form by using this code:

Private Sub Form_Current()
    Debug.Print "Form_Current: " & anzahlDatensätze
    lblAnzahlDatensätze.Caption = anzahlDatensätze & " Klient(en)"
End Sub

Private Function anzahlDatensätze() As Integer
    Dim rs As Recordset
    Set rs = Me.RecordsetClone
    rs.MoveLast
    anzahlDatensätze = rs.RecordCount
End Function

This works fine until I am using some filters. If I am using any filter on my form, the number of records stays unchanged!

  • What do I have to change to get the current number of records showing up (if filtered or not)?
  • What is the reason why my code does not show the correct number of records?

Access Project Overview

EDIT: According to the given comments and answers I tried setting Count([pkKlient] onto a textbox (see new pic) and tried DCount("*", "abfKlientenÜbersicht", me.Filter) from within VBA Code.

Unfortunatelly it seems that the filterClause is not valid when using it as parameter value for DCount. (see pic for filterClause).

As you can see count(..) does not result in a correct number – and the filterClause (generated by access!!) seems not to be valid for use by DCount(..)

If someone wants to try it, on your own, just create an ADP, add a form, add a view, form dataSource is a view, set a filter, and try to get the number of records?!!

Looking forward for any comments/answers/hints!

form Screenshot when filtered

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:04:20+00:00Added an answer on June 18, 2026 at 6:04 am

    Some notes, there are a dozen things that could go wrong with this, it could hardly even be called tested. However, it was returning the correct count for me.

    Apparently, the form filter just hides records, whereas this will apply a real filter. However, you need to get the format into the right shape for a valid filter. In the end, a WHERE statement would probably be easier.

    Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
    
        With Me.Recordset
            ''Filter
            If ApplyType = 1 Then
                ''Very, very roughly. Remove form name, use single quotes
                ''You will need a lot more code for safety
                sfilter = Replace(Me.Filter, "[" & Me.Name & "].", "")
                sfilter = Replace(sfilter, """", "'")
    
                .Filter = sfilter 
    
                MsgBox "Recordset : " & Me.Recordset.RecordCount & vbCrLf _
                & "Filtered : " & .RecordCount
    
            Else
                ''Remove filter - ApplyType 0
                .Filter = ""
            End If
    
        End With
    
    End Sub
    

    Additional note with similar caveats

    You can also set a textbox to something on these lines:

    =IIf([FilterOn]=True,DCount("id","ATable",
     Replace(Replace([Filter],"[" & [Name] & "].",""),"""","'")),Count([id]))
    

    (Remove the break in the line, it is cosmetic)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In MS Access 2010 which has an ODBS link to a SQL Server 2008,
Using SQL Server 2008 R2 we are looking for a way to select the
Using Microsoft SQL Server 2005, is there any way to see when a table
I am using Access 2010 as a front-end to a database on SQL Server
I am trying to create a stored procedure using pass-through query in SQL Server
I am using vb.net and Access 2010 as the database (.accdb) This works with
I am using Gradle to access the Artifactory. Artifactory has the particular dependencies but
Am building windows form application for a Hospital using VS2010 ON ACCESS 2010. I
I'm doing web project in tapestry by using jetty server in Eclipse. It works
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.