Results 1 to 3 of 3
  1. #1
    tweety is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Nov 2012
    Posts
    126

    count number of records on form using text box

    is there a way of counting the amount of records available in a form and to display them on in text box, e.g 5 of 12

    there is the record selector by default at the bottom of the form but as it comes with limited button such create next and forward record i chosen not to use that, and added my own buttons



    thanks

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    A form is a method to display data from tables or queries.
    You can use a Select query or a DCount function to determine the number of records in your recordset.
    You can keep your own counter to identify which record of the recordset, you are currently working wth.

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    For Label

    First you have to force Access to load the entire RecordSet, something the Access Gnomes don't always do when a Form first opens:

    Code:
    Private Sub Form_Load()
      DoCmd.GoToRecord , , acLast
      DoCmd.GoToRecord , , acFirst
    End Sub

    Then to update the count as you move from Record-to-Record:

    For a Label

    Code:
    Private Sub Form_Current()
      Me.LabelName.Caption = "Record  " & CurrentRecord & "  Of  " & RecordsetClone.RecordCount & "  Records"
    End Sub

    Actually, instead of using a separate Label and Me.LabelNameCaption, I usually use Me.Caption, which places the count in the very top of the Form itself, ala

    Record 1 of 300 Records

    If you also want a Form Name up there you could simply combine the two:

    Me.Caption = "The Yada Yada Form " & "Record " & CurrentRecord & " Of " & RecordsetClone.RecordCount & " Records"

    For Textbox

    Code:
    Private Sub Form_Current()
      Me.TextboxName = "Record  " & CurrentRecord & "  Of  " & RecordsetClone.RecordCount & "  Records"
    End Sub

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Replies: 1
    Last Post: 01-24-2013, 05:50 PM
  2. Replies: 10
    Last Post: 09-21-2012, 09:00 AM
  3. Replies: 6
    Last Post: 07-25-2011, 01:54 PM
  4. count the number of records from a query
    By Nixx1401 in forum Queries
    Replies: 4
    Last Post: 05-24-2011, 06:45 PM
  5. Count Text as Number
    By AccessFreak in forum Forms
    Replies: 1
    Last Post: 01-04-2011, 12:49 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