Results 1 to 4 of 4

Thread: Access form record count

  1. #1

    Thread Starter
    Fanatic Member WorkHorse's Avatar
    Join Date
    Jul 2002
    Location
    Where you live.
    Posts
    591

    Access form record count

    How do I get the query count to display on an Access form?

    I have a form in MS Access and want to simulate the navigation controls. So it says "This is record X of Y". X = Me.CurrentRecord. But what is Y? I tried Me.Count but it doesnt give the right number. The form sources a query, and I want to display the number of records in the query. Sorry, not real handy at Access forms. Any help would be appreciated. Thanks.

  2. #2
    Member
    Join Date
    Oct 2002
    Posts
    33
    Hi !

    Testing I found that TextBoxes in a Form with the values :

    1.- "=CurrentRecord" gives me the same that you say AND

    2.- "=Count(*)" gives me the total number of records in the source Query.

    Hope it works for you.

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Me.Recordcount

  4. #4
    New Member
    Join Date
    Nov 2010
    Posts
    4

    Re: Access form record count

    This was really annoying or me to figure out from a subform (it doesn't work if your main form has more than one subform). The workaround for a subform referencing a parent's recordcount is the following line of code:
    Code:
    Set sqlrs = CurrentDb.OpenRecordset("Select Count(*) AS My_Count FROM [" & frm.Parent.RecordSource & "]", dbOpenSnapshot, dbReadOnly)  
    varRecordCount = Nz(sqlrs![My_Count], 0)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width