How to Auto Generate a Primary Key everytime i print a report page in MS Acces

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sinfulm3
    New Member
    • May 2010
    • 3

    How to Auto Generate a Primary Key everytime i print a report page in MS Acces

    I have a MS Access 2003 database that i want to automate generating of an autonumber ID everytime i print.

    Example: I have a table Workorders with a WorkorderID which is a Primary Key and Autonumber. I want to have a print button wherein if i have to print 50 pages, all the 50 pages report will have different WorkorderID(inc rementing) on it.

    Or is this possible in a Query?
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    Hi.
    Originally posted by sinfulm3
    I have a MS Access 2003 database that i want to automate generating of an autonumber ID everytime i print.
    Autonumbers are used to identify unique rows in a table. Without knowing why you need to generate a new ID every time you print we can't advise you how to do it.

    Reports are generally passive documents which summarise entries made; your requirement to change something each time you run the report is not easy to interpret. Can you tell us a bit more about what it is you need, and perhaps post some example data?
    Or is this possible in a Query?
    Can't say for sure about what can or cannot be done in a query given that it is not clear what you need, but generating new IDs as such - no.

    -Stewart

    Comment

    • sinfulm3
      New Member
      • May 2010
      • 3

      #3
      Originally posted by Stewart Ross Inverness
      Hi.

      Autonumbers are used to identify unique rows in a table. Without knowing why you need to generate a new ID every time you print we can't advise you how to do it.

      Reports are generally passive documents which summarise entries made; your requirement to change something each time you run the report is not easy to interpret. Can you tell us a bit more about what it is you need, and perhaps post some example data?

      Can't say for sure about what can or cannot be done in a query given that it is not clear what you need, but generating new IDs as such - no.

      -Stewart
      hello sir. i've made a new post with an attachment of what i want to happen.

      this is the title of the post "MS Access New Record and Printing VBA Codes"

      thanks.

      Comment

      • 9815402440
        New Member
        • Oct 2007
        • 180

        #4
        hi
        if you just want to display serial number (incremented by given number) then you can use shape command. make a recordset using shape command as follows
        "shape {select * from Table1} append new adDouble numSrNo"
        use following loop then
        i=1
        while not rst.eof
        rst.fields("num SrNo").value = i
        i=i+1
        rst.movenext
        wend
        now bind the control with datareport

        regards
        manpreet singh dhillon hoshiarpur

        Comment

        Working...