Results 1 to 9 of 9

Thread: [ReReReSolved] make query to have a field that shows as rows number.

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Posts
    158

    Resolved [ReReReSolved] make query to have a field that shows as rows number.

    hi,
    i got a query like this

    Code:
    apple     2.50     3.40
    banana    2.40     2.90
    papaya    1.40     2.30
    mangoes   3.40     4.40
    what i hope is, the query would also show the number of the records.
    like below
    Code:
    1 apple     2.50     3.40
    2 banana    2.40     2.90
    3 papaya    1.40     2.30
    4 mangoes   3.40     4.40
    so, anyone of u have any idea.
    thanks in advance
    Last edited by asmdev; May 23rd, 2005 at 05:52 AM.

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: make query to have a field that shows as rows number.

    Use an autonumber (access) or auto increment number for the primary key and put that into the query - it won't always be sequential, but at least it would have a unique reference to the record.

    You do have a Primary Key already, correct?
    Does the record number really matter?

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Posts
    158

    Re: make query to have a field that shows as rows number.

    em, because i want the report to show the numbering records that it print out.
    like for the food sample above. so, if there any way to make a dummy field in our query to show something like autonumber according to the shown records?

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Posts
    158

    Re: make query to have a field that shows as rows number.

    hi, based on a solution given by rob in
    http://www.vbforums.com/showthread.php?t=339978

    instead of creating a dummy field in query, we could just create a textbox and set the value when the report runs. so, now my report have a numbering column.

    thanks rob

    VB Code:
    1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    2.     Static idCounter
    3.    
    4.     idCounter = idCounter + 1
    5.     txtId = idCounter
    6. End Sub

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Posts
    158

    Re: [ReOpen] make query to have a field that shows as rows number.

    while, my code got some problem

    let say, when we preview the report, we would see it is nice numbering
    from
    1
    2
    3
    4
    5
    6

    but if we print the report, we would get
    7
    8
    9
    10
    11
    12

    and i wonder whats wrong...?
    is it something to do with the Detail_Print? and wat is Detail_Retreat ????


    need urgent help.... sorry if it sounds annoy... but i really need to put this project finish to start another.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Posts
    158

    Re: [ReOpen] make query to have a field that shows as rows number.

    ok, settled

    VB Code:
    1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    2.     counterReport = counterReport + 1
    3.     txtId = counterReport
    4. End Sub
    5.  
    6. Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)
    7.     counterReport = 0
    8. End Sub

    the counterReport is a variable in module

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Posts
    158

    Re: [ReReSolved] make query to have a field that shows as rows number.

    no, i was wrong, we can't rely on the Detail_Format
    i just test it

    btw, we could trust Detail_Print

    VB Code:
    1. first page
    2. ==========
    3. Detail_Format : 1    10
    4. Detail_Format : 2    19
    5. Detail_Format : 3    4
    6. Detail_Format : 4    12
    7. Detail_Format : 5    20
    8. Detail_Format : 6    5
    9. Detail_Format : 7    1
    10. Detail_Format : 8    6
    11. Detail_Format : 9    6
    12. Detail_Format : 10    9
    13. Detail_Format : 11    18
    14. Detail_Format : 12    8
    15. Detail_Format : 13    13
    16. Detail_Format : 14    7
    17. Detail_Format : 15    15
    18. Detail_Format : 16    11
    19. Detail_Format : 17    16
    20. Detail_Format : 18    16
    21. Detail_Format : 19    10
    22. Detail_Format : 20    19
    23. Detail_Format : 21    4
    24. Detail_Format : 22    12
    25. Detail_Format : 23    20
    26. Detail_Format : 24    5
    27. Detail_Format : 25    1
    28. Detail_Format : 26    6
    29.  
    30. second page
    31. ===========
    32. Detail_Format : 27    6
    33. Detail_Format : 28    9
    34. Detail_Format : 29    18
    35. Detail_Format : 30    8
    36. Detail_Format : 31    13
    37. Detail_Format : 32    7
    38. Detail_Format : 33    15
    39. Detail_Format : 34    11
    40. Detail_Format : 35    16
    41.  
    42. third page
    43. ==========
    44. Detail_Format : 36    16

    while, when running on Detail_Print
    VB Code:
    1. first page
    2. ==========
    3. Detail_Print : 1    10
    4. Detail_Print : 2    19
    5. Detail_Print : 3    4
    6. Detail_Print : 4    12
    7. Detail_Print : 5    20
    8. Detail_Print : 6    5
    9. Detail_Print : 7    1
    10.  
    11. second page
    12. ===========
    13. Detail_Print : 8    6
    14. Detail_Print : 9    9
    15. Detail_Print : 10    18
    16. Detail_Print : 11    8
    17. Detail_Print : 12    13
    18. Detail_Print : 13    7
    19. Detail_Print : 14    15
    20. Detail_Print : 15    11
    21.  
    22. third page
    23. ==========
    24. Detail_Print : 16    16

    i attached with the database which i use to learn about this
    Attached Files Attached Files

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Posts
    158

    Re: [ReOpen] make query to have a field that shows as rows number.

    hi,
    the funny thing is, i suspect the access got a bug here.
    coz, when we print, we get different number !!

    anybody plez download the access file and try to print the report out.
    it is really funny, the printer show something different from print preview
    Last edited by asmdev; May 23rd, 2005 at 04:25 AM.

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Posts
    158

    Re: [ReOpen] make query to have a field that shows as rows number.

    ok, i finally got it solved

    the solution is to place a textbox (txtCount) in our report
    under the control source, key in "=1"

    and under the textbox which we wanna display our number, set the textbox control source to "=txtCount" and set the Running Sum to "Over Group"

    i attached with the solved ms access database.
    Attached Files Attached Files

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