Results 1 to 4 of 4

Thread: Counting records

  1. #1
    Senior Member
    Join Date
    Jul 2003
    Location
    Petersfield, UK
    Posts
    1,755
    Thanks
    0
    Thanked
    0 times in 0 posts

    Counting records

    Hi.

    Basically i am doing a project in Access, and using VB to program the extra bits, like If formulas etc.

    I want to make some custom record counters so they display the current record number and the total records. Like 5/10 or something. I know access do have this function on their forms but i want to get rid of it and make my own

    I cant find anything on the internet, does anyone have any idea how to program this in VB?

    Any help much appreciated.

    Will
    | XP1600-m | ASUS AN78X Deluxe | r9700 pro | 2x512mb pc37000 |

  2. #2
    Senior Member Shad's Avatar
    Join Date
    Jul 2003
    Location
    In front
    Posts
    2,782
    Thanks
    23
    Thanked
    42 times in 25 posts
    Well create your SQL something like...

    Code:
    SELECT (SELECT COUNT(prikey) FROM table) AS totrecs, fielda, fieldb, fieldc FROM table
    Then just increment a counter as you run through the recordset returned...

    Code:
    counter = 0
    Do while not RecSet.EOF
      counter = counter + 1
      'some code...
      RecSet.Movenext
    Loop
    Simon


  3. #3
    Pixel Abuser Spunkey's Avatar
    Join Date
    Nov 2003
    Location
    Milton Keynes
    Posts
    1,523
    Thanks
    0
    Thanked
    0 times in 0 posts
    if youre using ADO you can also get the number of records returned from any type of query (not just a COUNT *) - try myRS.RecordCount.

    you have to specify lock and cursortypes on your rs for that to work though, cant remember the proper names but if you open it like this it'll work
    myRS.open SQL, cn, 3, 1

  4. #4
    Senior Member
    Join Date
    Jul 2003
    Location
    Petersfield, UK
    Posts
    1,755
    Thanks
    0
    Thanked
    0 times in 0 posts
    Thanks very much guys. ill give that a go tonight
    | XP1600-m | ASUS AN78X Deluxe | r9700 pro | 2x512mb pc37000 |

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. 3 Months and counting
    By TiG in forum PC
    Replies: 3
    Last Post: 11-01-2004, 10:20 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
  •