How to Duplicate Table Entries by a Quantity?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Talnus
    New Member
    • Jun 2010
    • 4

    How to Duplicate Table Entries by a Quantity?

    This question is completely backwards, to what a database is suppose to do, however because of the interaction between two systems it needs to be this way. I am looking for some way to have a report display the information bellow.

    I am simplifying the problem to what I am trying to accomplish. I need to have quantities be able to repeat an entry as many times as there are quantities.

    OrderNumber, QTY, PartNumber
    PO0001, 2, PN-01
    PO0001, 1, PN-02
    PO0001, 3, PN-06

    Result needed or Output needed.
    Unit A PO0001, PN-01
    Unit B PO0001, PN-01
    Unit C PO0001, PN-02
    Unit D PO0001, PN-06
    Unit E PO0001, PN-06
    Unit F PO0001, PN-06

    Does anyone have any ideas on how to accomplish this?
    Thanks for the help.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32633

    #2
    I would suggest this needs some VBA coding including a loop.

    Open two recordsets and process through the first inputting the data. Next, or should I say after each individual record has been read from the first recordset, write out the data to the other recordset n times.

    Access VBA DAO Recordset Loop Using Two Recordsets may help as a basic template for your code. Let us know how you get on with this.

    Welcome to Bytes!

    Comment

    • FishVal
      Recognized Expert Specialist
      • Jun 2007
      • 2656

      #3
      Originally posted by Talnus
      This question is completely backwards, to what a database is suppose to do, however because of the interaction between two systems it needs to be this way. I am looking for some way to have a report display the information bellow.

      I am simplifying the problem to what I am trying to accomplish. I need to have quantities be able to repeat an entry as many times as there are quantities.

      OrderNumber, QTY, PartNumber
      PO0001, 2, PN-01
      PO0001, 1, PN-02
      PO0001, 3, PN-06

      Result needed or Output needed.
      Unit A PO0001, PN-01
      Unit B PO0001, PN-01
      Unit C PO0001, PN-02
      Unit D PO0001, PN-06
      Unit E PO0001, PN-06
      Unit F PO0001, PN-06

      Does anyone have any ideas on how to accomplish this?
      Thanks for the help.
      Copying record to a table several times

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32633

        #4
        Trumped!

        That's a better solution I would say.

        Comment

        • Talnus
          New Member
          • Jun 2010
          • 4

          #5
          Ahhh that worked GREAT!!! Thanks!!!

          Comment

          Working...