Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    Jan 2002
    Location
    Washington State
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Show Record Number (A2K)

    Hi!

    In my query, I'd like to be able to display the row number of each record. I'll be using this query as the rowsource for a listbox.

    In a simplified example I'd want my listbox to display:
    1 Apples
    2 Oranges
    3 Cherries
    4 Plums

    etc. Is there some kind of rowcounter function that can be used here?

    Thanks!
    Sam

  2. #2
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    USA
    Posts
    386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Show Record Number (A2K)

    As I understand it, Access does not keep "Row Count" on the data in a table. You can get a count of the rows in a record set, but that is the total number of rows returned.

    One way to get what you are looking for is to create a simple function the will increment 1 for each row returned by the query.

    function PlusOne() as Integer
    g_iCounter = g_iCounter + 1
    PlusOne = g_iCounter
    end function


    Hope this helps.
    Richard

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Show Record Number (A2K)

    Unless you have a field whose value increases with the value displayed in the query, this is difficult. You could create a temporary table with a sequential counter: see ACC2000: How to Simulate a Dynamic Counter in a Table or a Query to Count Records.

  4. #4
    Star Lounger
    Join Date
    Jan 2002
    Location
    Washington State
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Show Record Number (A2K)

    Thanks Hans!

    Creating a temporary table like that will work just fine for me.

    Appreciate the help!
    Sam

Posting Permissions

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