How to number records in data report

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mdtam
    New Member
    • Jan 2013
    • 22

    How to number records in data report

    Hi experts,

    I'm using Visual Basic 6, MS Access as Database and Data Environment in my Data Report. I would like to give numbers for my selected data. I separated my data and the numbers then used this code.
    Code:
    SELECT Customers.CustomerID, Customers.CompanyName, 
    (SELECT Count(*) From Customers As Rank Where Rank.CustomerId <= Customers.CustomerId) AS RecordNumber
    FROM Customers
    ORDER BY Customers.CustomerID;
    The problem is it's not produce sequence numbers. Thanks for your help.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    It would help to see sample data, what your current code is producing, and what it's supposed to produce instead.

    Comment

    • mdtam
      New Member
      • Jan 2013
      • 22

      #3
      it's produce numbers but not sequence like
      3.
      5.
      2.

      I would like it produces like
      1.
      2.
      3.
      until the end.

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        I still need to see the sample data that is producing those results.

        Comment

        • mdtam
          New Member
          • Jan 2013
          • 22

          #5
          my data looks like this:
          Code:
          CustomerID    Company Name 
            111           kolapis          
            121           nangka            
            131           atec              
            122           vis               
            152           dell
          let's say I choose atec,dell and nangka. I would like the numbers in data report sequence 1, 2, 3.

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            There's the issue then. You're filtering for certain companies in your query but not filtering in your subquery as well.

            Comment

            Working...